本文目录一览:
- 1、我在淘宝上看的二手笔记本电脑才390,我想买个学习c语言,用来写代码,不知道这么便宜敢买吗???
- 2、C语言出错图形模式下显示字符
- 3、【c语言】学到指针。。跟着书本输入,可还是出现问题。。。错误代码:无法识别的声明。
- 4、c语言中的时钟问题
我在淘宝上看的二手笔记本电脑才390,我想买个学习c语言,用来写代码,不知道这么便宜敢买吗???
你要是敢买,我第一个服你!
千万别买,这水深得很。
多花一点钱,两三千的电脑写代码是没什么问题的,但是也不至于便宜到390。
兄弟,那不是便宜,那是一个坑啊
C语言出错图形模式下显示字符
#include"graphics.h"
main()
{
int drive,mode;
drive=DETECT;//大写 必须大写
initgraph(drive,mode,"c:\\tc30\\bgi");
cleardevice();
setcolor(12);
circle(320,380,50);
setfillstyle(SOLID_FILL,LIGHTRED);//大写
floodfill(320,375,12);
setkcolor(7);
setfillstyle(SOLID_FILL,GREEN);//大写
bar(0,380,639,479);
setcolor(14);
line(0,380,639,380);
line(0,390,639,390);
line(0,410,639,410);
line(0,440,639,440);
line(0,479,639,479);
line(0,400,60,380);
line(0,430,130,380);
line(0,479,200,380);
line(120,479,245,380);
line(210,479,280,380);
line(280,479,310,380);
line(360,479,330,380);
line(430,479,360,380);
line(520,479,395,380);
line(639,479,450,380);
line(639,430,520,380);
line(639,400,590,380);
settextstyle(1,0,4);
moveto(100,150);
outtext("press any key to continue...");
getch();
closegraph();
}
【c语言】学到指针。。跟着书本输入,可还是出现问题。。。错误代码:无法识别的声明。
if(*buffer_length)这里错,buffer_length是个整形,不能取*操作
另外,以后提这种问题,如果不能贴完整代码,拜托把行号显示出来
你这次是39行,要是390行,估计没有人会帮你看的。
c语言中的时钟问题
#include"stdio.h"
#include"graphics.h"
#include"math.h"
#include"time.h"
#include"dos.h"
int point_sec,point_min,point_hour;
int x,y,z;
int array_sec[60][2];
int array_min[60][2];
int array_hour[60][2];
int a[60][2];
void zhongmian()
{
int n,m,p;
x=320;
y=240;
z=140;
point_sec=132;
point_min=110;
point_hour=90;
setfillstyle(1,2);
setlinestyle(0,0,3);
ellipse(x,y,0,180,220,150);
setlinestyle(0,0,3);
ellipse(x,y,180,360,220,150);
ellipse(x,y,90,270,210,150);
ellipse(x,y,90,270,200,150);
ellipse(x,y,90,270,190,150);
ellipse(x,y,90,270,180,150);
ellipse(x,y,90,270,170,150);
ellipse(x,y,90,270,160,150);
ellipse(x,y,90,270,150,150);
ellipse(x,y,270,90,150,150);
ellipse(x,y,270,90,160,150);
ellipse(x,y,270,90,170,150);
ellipse(x,y,270,90,180,150);
ellipse(x,y,270,90,190,150);
ellipse(x,y,270,90,200,150);
ellipse(x,y,270,90,210,150);
setcolor(3);
ellipse(x,80,25,155,72,72);
ellipse(x,80,40,140,55,55);
setcolor(RED);
circle(x,y,148);
floodfill(165,240,RED);
floodfill(145,240,RED);
floodfill(125,240,RED);
floodfill(105,240,RED);
floodfill(475,240,RED);
floodfill(495,240,RED);
floodfill(515,240,RED);
floodfill(535,240,RED);
setlinestyle(0,0,3);
line(135,320,90,420);
line(505,320,550,420);
line(90,420,550,420);
arc(x,y,26,154,200);
setcolor(YELLOW);
arc(x,y,32,147,192);
setcolor(YELLOW);
setfillstyle(1,1);
floodfill(250,400,RED);
putpixel(320,100,YELLOW);
fillellipse(320,100,5,5);
putpixel(390,119,YELLOW);
fillellipse(390,119,5,5);
putpixel(441,170,YELLOW);
fillellipse(441,170,5,5);
putpixel(460,240,YELLOW);
fillellipse(460,240,5,5);
putpixel(441,310,YELLOW);
fillellipse(441,310,5,5);
putpixel(390,361,YELLOW);
fillellipse(390,361,5,5);
putpixel(320,380,YELLOW);
fillellipse(320,380,5,5);
putpixel(250,361,YELLOW);
fillellipse(250,361,5,5);;
putpixel(199,310,YELLOW);
fillellipse(199,310,5,5);
putpixel(180,240,YELLOW);
fillellipse(180,240,5,5);;
putpixel(199,170,YELLOW);
fillellipse(199,170,5,5);;
putpixel(250,119,YELLOW);
fillellipse(250,119,5,5);;
for(p=6,n=0,m=0;n15;p=p+6,n++,m++){
a[m][0]=(int)(x+z*sin(2*3.14*p/360));
a[m][1]=(int)(y-z*cos(2*3.14*p/360));
array_sec[m][0]=(int)(x+point_sec*sin(2*3.14*p/360));
array_sec[m][1]=(int)(y-point_sec*cos(2*3.14*p/360));
array_min[m][0]=(int)(x+point_min*sin(2*3.14*p/360));
array_min[m][1]=(int)(y-point_min*cos(2*3.14*p/360));
array_hour[m][0]=(int)(x+point_hour*sin(2*3.14*p/360));
array_hour[m][1]=(int)(y-point_hour*cos(2*3.14*p/360));
}
for(p=6,n=0;n15;p=p+6,n++,m++){
a[m][0]=(int)(x+z*cos(2*3.14*p/360));
a[m][1]=(int)(y+z*sin(2*3.14*p/360));
array_sec[m][0]=(int)(x+point_sec*cos(2*3.14*p/360));
array_sec[m][1]=(int)(y+point_sec*sin(2*3.14*p/360));
array_min[m][0]=(int)(x+point_min*cos(2*3.14*p/360));
array_min[m][1]=(int)(y+point_min*sin(2*3.14*p/360));
array_hour[m][0]=(int)(x+point_hour*cos(2*3.14*p/360));
array_hour[m][1]=(int)(y+point_hour*sin(2*3.14*p/360));
}
for(p=6,n=0;n15;p=p+6,n++,m++){
a[m][0]=(int)(x-z*sin(2*3.14*p/360));
a[m][1]=(int)(y+z*cos(2*3.14*p/360));
array_sec[m][0]=(int)(x-point_sec*sin(2*3.14*p/360));
array_sec[m][1]=(int)(y+point_sec*cos(2*3.14*p/360));
array_min[m][0]=(int)(x-point_min*sin(2*3.14*p/360));
array_min[m][1]=(int)(y+point_min*cos(2*3.14*p/360));
array_hour[m][0]=(int)(x-point_hour*sin(2*3.14*p/360));
array_hour[m][1]=(int)(y+point_hour*cos(2*3.14*p/360));
}
for(p=6,n=0;n15;p=p+6,n++,m++){
a[m][0]=(int)(x-z*cos(2*3.14*p/360));
a[m][1]=(int)(y-z*sin(2*3.14*p/360));
array_sec[m][0]=(int)(x-point_sec*cos(2*3.14*p/360));
array_sec[m][1]=(int)(y-point_sec*sin(2*3.14*p/360));
array_min[m][0]=(int)(x-point_min*cos(2*3.14*p/360));
array_min[m][1]=(int)(y-point_min*sin(2*3.14*p/360));
array_hour[m][0]=(int)(x-point_hour*cos(2*3.14*p/360));
array_hour[m][1]=(int)(y-point_hour*sin(2*3.14*p/360));
}
for(n=0;n60;n++)
putpixel(a[n][0],a[n][1],YELLOW);
}
void zhuandong()
{
struct tm * p;
time_t l;
int n,m,i,q,b,c,sec,min,hour;
n=61;
m=61;
i=61;
b=0;
c=0;
while(1){
l=time(NULL);
p=localtime(l);
sec=p-tm_sec;
min=p-tm_min;
hour=p-tm_hour;
gotoxy(29,12);
if(n==sec){
setcolor(0);
setlinestyle(0,0,1);
line(x,y,array_sec[(sec+58)%60][0],array_sec[(sec+58)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+58)%60][0],array_min[(min+58)%60][1]);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+58)%60][0],array_hour[(hour%12*5+min/12+58)%60][1]);
setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+59)%60][0],array_min[(min+59)%60][1]);
printf("%s",asctime(p));
sound(50);
delay(100);
nosound();
setcolor(YELLOW);
setlinestyle(0,0,1);
line(320,240,array_sec[(sec+59)%60][0],array_sec[(sec+59)%60][1]);
}
n=sec+1;
if(n==60)n=0;
if(b==0)
{m=min;b=1;}
if(min==m){
setcolor(0);
setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+59)%60][0],array_min[(min+59)%60][1]);
}
m=min+1;
if(m==60)m=0;
if(c==0)
{i=min;c=1;}
if(i==min){
setcolor(0);
setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);
}
i=min+1;
if(i==60)i=0;
if(kbhit())exit(1);
}
}
main()
{
int gdriver,mode;
gdriver=VGA;
mode=VGAHI;
registerbgidriver(EGAVGA_driver);
initgraph(gdriver,mode,"");
setbkcolor(0);
setcolor(RED);
zhongmian();
zhuandong();
closegraph();
}