2013年10月7日

摘要: #includeint main(void){ int i; char ch_lower,ch_upper; for(i=1;i='a'&&ch_lower%c->%d\n",ch_lower,ch_upper,ch_upper%10); } return 0;}#includeint main(void){ char ch='w'; int a=2,b=3,c=1,d,x=10; printf("%d",a>b==c); printf("%d",d=a>b); printf(& 阅读全文
posted @ 2013-10-07 18:50 ChapterCold 阅读(182) 评论(0) 推荐(0) 编辑
 
摘要: #includeint main(void){ double height,radius,volume; double cylinder(double r,double h); printf("Enter radius and height:"); scanf("%lf%lf",&radius,&height); volume=cylinder(radius,height); printf("Volume=%.3f\n",volume); return 0;}double cylinder(double r,doubl 阅读全文
posted @ 2013-10-07 18:37 ChapterCold 阅读(130) 评论(0) 推荐(0) 编辑
 
摘要: #include#includeint main(void){ int denominator,flag; double item,pi; flag=1; denominator=1; item=1.0; pi=0; while(fabs(item)>=0.0001){ item=flag*1.0/denominator; pi=pi+item; flag=-flag; denominator=denominator+2; } pi=pi*4; printf("pi=%.4f\n... 阅读全文
posted @ 2013-10-07 11:05 ChapterCold 阅读(121) 评论(0) 推荐(0) 编辑
 
摘要: #includeint main(void){ int mynumber=38; int yournumber; printf("Input your number:"); scanf("%d",&yournumber); if(yournumber==mynumber) printf("Ok!you are right!\n"); else if(yournumber>mynumber) printf("Sorry!your number is bigger than my number!\n"); 阅读全文
posted @ 2013-10-07 10:39 ChapterCold 阅读(109) 评论(0) 推荐(0) 编辑
 
摘要: #includeint main(void){ printf("Hello World!\n"); return 0;}#includeint main(void){ printf("Programming is fun.\n"); printf("And programming in C is even more fun!\n"); return 0;}#includeint main(void){ int celsius,fahr; fahr=100; celsius=5*(fahr-32)/9; printf("fah 阅读全文
posted @ 2013-10-07 10:21 ChapterCold 阅读(107) 评论(0) 推荐(0) 编辑
 
摘要: #includeint main(void){ int n; int factorial(int n); scanf("%d",&n); printf("%d\n",factorial(n)); return 0;}int factorial(int n){ int i,fact=1; for(i=1;i<=n;i++) fact=fact*i; return fact;} 阅读全文
posted @ 2013-10-07 10:06 ChapterCold 阅读(77) 评论(0) 推荐(0) 编辑
 
摘要: #include#includeint IsPrime(int a){ int i; for(i=2;i<=sqrt(a);i++) if(a%i==0)return 0; return 1;}int main(){ int a; printf("请输入一个正整数a:"); scanf("%d",&a); if(IsPrime(a))printf("%d是一个质数\n",a); else printf("%d不是一个质数\n",a);} 阅读全文
posted @ 2013-10-07 09:38 ChapterCold 阅读(91) 评论(0) 推荐(0) 编辑
 
摘要: #includeint main(){ int i; long m; float f; double d; printf("sizeof(int)=%d,sizeof(i)=%d,&i=%x\n",sizeof(int),sizeof(i),&i); printf("sizeof(long)=%d,sizeof(m)=%d,&m=%x\n",sizeof(long),sizeof(m),&m); printf("sizeof(float)=%d,sizeof(f)=%d,&f=%x\n",siz 阅读全文
posted @ 2013-10-07 09:33 ChapterCold 阅读(81) 评论(0) 推荐(0) 编辑