摘要: 1.编写程序,统计字符串中大写字母的个数。 #include<stdio.h>main(){char str[20];int i,cnt;cnt=i=0;gets(str);while(str[i]!='\0'){if(str[i]>='A'&&str[i]<='Z')cnt++;i++;}prin 阅读全文
posted @ 2021-12-02 20:42 Yz、 阅读(10) 评论(0) 推荐(0)
摘要: 1.定义一个含有8个储存单元的实行数组,从键盘上接收数,然后逆序输出。 #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]);} 阅读全文
posted @ 2021-12-02 20:39 Yz、 阅读(21) 评论(0) 推荐(0)
摘要: 1.随机产生一个0-99的数,猜猜看,如果大了,就显示大了点;如果小了,就显示小了点,直到猜对为止。 #include<stdio.h>#include<stdlib.h>#include<time.h>int main(){int a,n;srand((unsigned)time(NULL));a 阅读全文
posted @ 2021-12-02 20:35 Yz、 阅读(33) 评论(0) 推荐(0)
摘要: 1.输出以下图形 * ** *** **** ***** #include<stdio.h> main() { int i,j,k; for(i=1;i<=5;i++) { for(j=1;j<=5-1;j++){ printf(" "); } for(k=1;k<=i;k++){ printf(" 阅读全文
posted @ 2021-11-11 23:11 Yz、 阅读(15) 评论(0) 推荐(0)
摘要: 1.编写程序,使用while语句求和sum=1+3+5+···+21。 #include<stdio.h>main(){int i=1;int sum=0;while(i<=21){sum+=i;i+=2;}printf("Sum=%d\n",sum);} 2.编写程序,使用while语句求和sum 阅读全文
posted @ 2021-11-11 23:08 Yz、 阅读(16) 评论(0) 推荐(0)
摘要: 1.编写程序判断n是整数还是负数。 #include<stdio.h>main(){int n;printf("输入一个整数:\n");scanf("%d",&n);if(n>0)printf("%d是正数!\n",n);elseif(n==0)printf("%d既不是正数,也不是是负数!\n", 阅读全文
posted @ 2021-11-11 23:03 Yz、 阅读(13) 评论(0) 推荐(0)
摘要: #include<stdio.h> main() { int mark; printf("请输入学生的分数(0-100):\n"); scanf("%d",&mark); switch(mark/10) { case 10: case 9:printf("A\n"); case 8:printf(" 阅读全文
posted @ 2021-10-29 13:11 Yz、 阅读(26) 评论(0) 推荐(0)
摘要: 1.编写程序,判断一个数n是正数还是负数。 #include<stdio.h>main(){float n;scanf("%f",&n);if(n>0)printf("正数!\n");else if(n==0)printf("0既不是正数,也不是负数!\n");elseprintf("负数\n"); 阅读全文
posted @ 2021-10-24 16:22 Yz、 阅读(41) 评论(0) 推荐(0)
摘要: 1.编写程序,使用scanf()函数接收整型、实型、字符型的变量,并分行依次输出。 #include<stdio.h>main(){int a;float b;char c;scanf("%d%f%c",&a,&b,&c);printf("%d\n%f\n%c\n",a,b,c);} 2.编写程序, 阅读全文
posted @ 2021-10-24 16:18 Yz、 阅读(39) 评论(0) 推荐(0)
摘要: 编写程序,定义两个整形变量,赋值并输出 #include<stdio.h> main() { int a=5; int b=7; printf("%d %d\n",a,b); } 编写程序,定义一个单精度和一个双精度的变量,赋值并输出。 #include<stdio.h> main() { floa 阅读全文
posted @ 2021-10-14 22:52 Yz、 阅读(31) 评论(0) 推荐(0)