摘要:
1这题要注意int和double的使用#includeint main(void){int num1,num2,a,b,c,e;double d;printf("Enter num1 and num2:");scanf("%d%d",&num1,&num2);a=num1+num2;b=num1-num2;c=num1*num2;d=num1/num2;e=num1%num2;printf("h=%d,c=%d,j=%d,s=%Lf,y=%d\n",a,b,c,d,e);return 0;}3#includeint m 阅读全文
摘要:
#includeint main(void){ double r,s; double cylinder(double r); printf("Enter r:"); scanf("%lf",&r); if(r0){ s=3.1415926*r*r; printf("s=%.3f\n",s); } return 0;}#includeint main(void){ int i,n; double r,h,v; double cylinder(double r,double h); printf("Enter n:&qu 阅读全文
摘要:
这个假期基本时间都花在这个作业上了,没有什么体会终归是说不过去的。刚开始打的时候完全不懂,空格的一个一个对有没有打错,单词什么意思也记不住,一次又一次记scanf是输入、printf是输出等等。到后期熟了打代码的速度都会快一点,,出错率也大大降低。我有两次完全找不出错误的地方,一次是lf以为是if,或者把l当成1。另一次是3-10里case‘ ’中的空格漏了。这两个问题后来都是找助教帮忙搞定的。除了掌握了异错点之外,还学会用不同的源程序得出相同的运行结果。在时代飞速发展的今天,计算机越来越重要,而掌握了C语言,能让我们更加了解计算机的使用,也让自己掌握了一门技能。想要学好C语言,纸看书时不行的 阅读全文
摘要:
#include#include char* month_str[]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};intmon_day[][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31, 阅读全文
摘要:
#includeint main(void){ int i,number; char str[10]; printf("Enter a string:"); i=0; while((str[i]=getchar())!='\n') i++; str[i]='\0'; number=0; for(i=0;str[i]!='\0';i++) if(str[i]>='0'&& str[i]int main(void) { int count[9]; int i,response; for(i=1 阅读全文
摘要:
#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(& 阅读全文
摘要:
#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, doub 阅读全文
摘要:
#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... 阅读全文
摘要:
#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"); 阅读全文
摘要:
2-1#include int main(void) { printf("Hello World!\n"); return 0; }2-2#includeint main(void){ printf("Programming is fun.\n"); printf("And programming in C is even more fun!\n"); return 0;}2-3#includeint main(void){ int celsius,fahr; ... 阅读全文