摘要: 1.输入一个三位数,求个位,十位,百位. #include<stdio.h> main(){ int i,g,s,b; scanf("%d",&i); g=i%100%10; s=i/10%10; b=i/100; printf("个位是%d\n十位是%d\n百位是%d\n",g,s,b); } 2 阅读全文
posted @ 2021-12-06 20:18 计算机2107赵瑞 阅读(39) 评论(0) 推荐(0)
摘要: 1.编写程序,统计字符串中大写字母的个数。 #include<stdio.h> main(){ char a[10]; int b=0,c=0; gets(a); while(a[b]!='\0') { if(a[b]>='A'&&a[b]<='Z') c++; b++; } printf("%d\ 阅读全文
posted @ 2021-12-06 20:15 计算机2107赵瑞 阅读(36) 评论(0) 推荐(0)
摘要: 1.P121 1 #include<stdio.h> main(){ double m[8]; int i; for(i=0;i<=7;i++) scanf("%lf",&m[i]); for(i=7;i>=0;i--) printf("%f",m[i]); } 2.P121 2 #include< 阅读全文
posted @ 2021-12-06 20:11 计算机2107赵瑞 阅读(27) 评论(0) 推荐(0)
摘要: 1.编写程序,使用while语句求和sum=1+3+5+7+…+21。 #include<stdio.h> main(){ int a=1,sum=0; while(a<22){ if(a%2<=1) sum+=a; a+=2; } printf("%d\n",sum); } 2.编写程序,使用wh 阅读全文
posted @ 2021-12-06 20:05 计算机2107赵瑞 阅读(39) 评论(0) 推荐(0)
摘要: 1. 编写程序判断n是正数还是负数。 #include<stdio.h> main(){ int n; scanf("%d",&n); if(n>0) printf("正数"); else if(n==0) printf("非正非负"); else printf("负数"); } 2.使用条件运算符 阅读全文
posted @ 2021-12-06 19:57 计算机2107赵瑞 阅读(34) 评论(0) 推荐(0)
摘要: 1.教材P52 例4-8 分数转成等级 switch #include <stdio.h> main(){ int mark; printf("请输入学生分数:\n"); scanf("%d",&mark); switch(mark/10) { case 10: //与case 9:共用一条语句 c 阅读全文
posted @ 2021-10-28 21:55 计算机2107赵瑞 阅读(39) 评论(0) 推荐(0)
摘要: 1. #include<stdio.h> main() { int a; float b; double c; char d; scanf("%d\n%f\n%lf\n%c",&a,&b,&c,&d); printf("%d\n%f\n%lf\n%f",a,b,c,d); } 2. #include 阅读全文
posted @ 2021-10-18 13:06 计算机2107赵瑞 阅读(22) 评论(0) 推荐(0)
摘要: 1.编写程序,定义两个 #include<stdio.h> main() { int a=2; int b=6; printf("%d%d\n",a,b); } 2.编写程序,定义一个单精度和一个双精度的变量,赋值并输出。 #include<stdio.h> main() { float a=1.2 阅读全文
posted @ 2021-10-14 21:36 计算机2107赵瑞 阅读(20) 评论(0) 推荐(0)
摘要: 1.编写程序,输出"我爱学习c语言!“ #include<stdio.h> main(){ printf("我爱学习c语言"); } 2.分行输出自己的专业和姓名。 #include<stdio.h> main(){ printf("计算机2107\n"); printf("赵瑞\n"); } 3. 阅读全文
posted @ 2021-10-04 15:22 计算机2107赵瑞 阅读(32) 评论(0) 推荐(0)