part 1
# include<stdio.h> int main() { printf("201883300055"); return 0; }
会出现忘记加;的错误。
# include<stdio.h> int product (int,int); int main (void) { int x,y,s; scanf("%d %d",&x,&y); s = product(x,y); printf("The mul is:%d",s); return 0; } int product(int a,int b) { int mul; mul=a*b; return mul; }
出现错误就是单词拼写错,忘记加;符号。
#include <stdio.h> int main() { int a=5,b=7,c=100,d,e,f; d=a/b*c; e=a*c/b; f=c/b*a; printf("d=%d,e=%d,f=%d\n",d,e,f); return 0; }
也是一些细节问题,忘记空格等等。
part 2
判断奇偶
#include <stdio.h> int main() { int x; printf("输入一个整数:\n"); scanf("%d",&x); if(x%2!=0) printf("是奇数"); else printf("是偶数"); return 0; }
根据不同的输入,显示不同的信息
#include <stdio.h> int main(){ int days; printf("输入一个整数:\n"); scanf("%d",&days); if(1<=days&&days<=5) printf("workdays,fighting\n"); else if(days==6||days==7) printf("weekend,relax~\n"); else printf("Ooops, not in 1~7\n"); return 0; }
根据用户输入字符,判断如果是小写字母,则转化成大写;否则保持原样
#include<stdio.h> int main(){ char ch; printf("输入一个字符:\n"); scanf("%c",&ch); if(ch>=‘a‘&&ch<=‘z‘) ch=ch-32; printf("%c\n",ch); return 0; }
总结与体会:第一次以这种形式完成作业,确实遇到很多小磕绊,但还是完成了。刚开始,看起来很简单,但遇到了很多细节问题,编译后错了许多,然后
分析问题,改正。后面补写的参考书本完成的。这次作业还做了蛮久的,在其中发现了它有趣的地方,但也有找错误找很长时间的时候。期待
更深入地学习c语言。
原文:https://www.cnblogs.com/lxx13/p/10583128.html