简单易懂的C语言源代码(供初学者使用)_第1页
简单易懂的C语言源代码(供初学者使用)_第2页
简单易懂的C语言源代码(供初学者使用)_第3页
简单易懂的C语言源代码(供初学者使用)_第4页
简单易懂的C语言源代码(供初学者使用)_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#include main() float pi=3.,r; printf(enter radius:n); scanf(%f,&r); printf(r=%.2f,c=%.2f,area=%.2fn,r,2*pi*r,pi*r*r); system(pause); #include main() int m,n,x,y; printf(inputm,n:n); scanf(%d%d,&m,&n); if (n%2=1) printf(error! n bu shi ji shu!n,n); return; /*n在这里不能是奇数*/ x=(4*m-n)/2; y=(n-2*m)/2; if(

2、x=0)&(y=0) printf(x=%d,y=%dn,x,y); else printf(shu ru cuo wu!n); getch(); #include #include #include main() float a,b,C; printf(enter 3number(a,b,C):n); scanf(%.2f %.2f %.2f,&a,&b,&C); s=0.5*a*b*sinC; printf(s=%.2fn,s); system(pause); #include main() int ds,nl,yf; char c; printf(shu ru ds;n); scanf(

3、%d,&ds); if (ds1184) printf(input error!press any end.n); scanf(%c,&c); exit(0); /*输入的数字必须是-141184之间*/ nl=(ds+115)%100; yf=(ds+115)/100; printf(nl=%d,yf=%dn,nl,yf); system(pause); #include #include main() char s1100,s2100,s3100,s4100; printf(input a string:n); gets(s1); strcpy(s1,s2); strcat(s1,-);

4、strcpy(s3,strcat(s1,-); strcat(strcpy(s3,strcat(s1,-),s2); strcpy(s4,strcat(strcpy(s3,strcat(s1,-),s2); puts(s4); system(pasue); getch(); #include #include main() float x1,x2,a,b,c; printf(input 3 number(a,b,c):n); scanf(%f%f%f,&a,&b,&c); x1=(-b+sqrt(b*b-4*a*c)/(2*a); x2=(-b-sqrt(b*b-4*a*c)/(2*a); p

5、rintf(x1=%f,X2=%fn,x1,x2); system(pause); getch(); #include main() int a,b,c,t; printf(input 3 number:n); scanf(%d%d%d,&a,&b,&c); if(ab) t=a;a=b,b=t; if(ac) t=a;a=c;c=t; if(bc) t=b;b=c;c=t; printf(1:%d,2:%d,3:%dn,a,b,c); system(pause); #include #include #include main() float pi=3.,r; textbackground(

6、YELLOW);/* 设置背景色为黄色,注意颜色应该大写,可更改 */ textcolor(RED); /* 设置文件颜色为红色,可更改 */ clrscr(); /* 清屏,使设置生效 */ printf(enter radius:); scanf(%f,&r); if(r0) printf(Enter Error!n); else printf(r=%.2f,c=%.2f,area=%.2fn,r,2*pi*r,pi*r*r); system(pause);/* 暂停,按任一键继续 */ #include #include #include main() float a,b,c,delt,

7、x1,x2,p,q; textcolor(YELLOW); clrscr(); printf(Input a b c:n); scanf(%f%f%f,&a,&b,&c); if(a=0) printf(Its not a quadratic equation!n); system(pause); return; delt=b*b-4*a*c; if(delt=0) x1=(-b+sqrt(delt)/(2*a); x2=(-b-sqrt(delt)/(2*a); printf(x1=%.3f x2=%.4fn,x1,x2); else p=-b/(2*a);q=sqrt(-delt)/(2*

8、a); printf(p=%.4fq=%.4fn,p,q); system(pause); getch(); #include main() float pi=3.,r; int k=0; while(k=3) printf(enter radius:n); scanf(%f,&r); printf(r=%.2f,c=%.2f,area=%.2fn,r,2*pi*r,pi*r*r); printf(press any key to continuenpress esc to exit.); k+; #include #include #include #include main() int a

9、,b,c,oper; long limit,i=0; char char1; textcolor(GREEN);/*设置字体颜色为绿色*/ clrscr(); /*清屏,是设置生效*/ while(i=3) printf(qing xuan ze jia huo jian(1or2,1:+,2:-n); scanf(%d,&oper); printf(Enter max (10000):n); scanf(%ld,&limit); srand(unsigned long)time(0); a=rand()*limit/RAND_MAX; b=rand()*limit/RAND_MAX; whi

10、le(ab)&(oper=2) a=rand()*limit/RAND_MAX; b=rand()*limit/RAND_MAX; char1=(oper=2?-:+); printf(%d%c%dn,a,char1,b); scanf(%d,&c); if(oper=2&a-b=c)|(oper!=2&a+b=c) printf(OK!You are very clever!n); else printf(The result is not correct!n); i+; getch(); #include #include main() int y,i=0; textcolor(YELLO

11、W); /*天下事无难易之分只有做与不做之别*/ textbackground(GREEN); clrscr();/*清屏,是设置生效*/ while(i=3) printf(Input year:n); scanf(%d,&y); if(y%4=0) if(y%100=0) if(y%400=0) printf(y shi run nian!n); else printf(y bu shi run nian !n); else printf(y shi run nian!n); else printf(y bu shi run nian!); i+; getche(); #include#i

12、nclude#includemain()int xz,wday1,hour1;struct tm *timeptr;time_t secsnow;char s130,s230,s330;printf(input whom do you say to?:n);scanf(%d,&xz);if(xz=1)strcpy(s1,mother);else if(xz=2)strcpy(s1,father);elsestrcpy(s1,);time(&secsnow);timeptr=localtime(&secsnow);wday1=timeptr-tm_wday;if(wday1=6)strcpy(s

13、2,Happy saturday!);else if(wday1=0)strcpy(s2,Happy sunday);elsestrcpy(s2,);hour1=timeptr-tm_hour;if(hour1=4&hour1=17&hour1=22)strcpy(s3,Good afternoon!);elsestrcpy(s3,Good evening!);printf(%s%s%s,s1,s2,s3);getch();#include#includemain()int day,year,month,i=0;textbackground(BROWN);clrscr();while(i=3)printf(Input 2 number:n);scanf(%d%d,&year,&month);switch(month)case 1:case 3:case 5:case 7:case 8:case 10:case 12: day=31;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论