摘要: 输入一个三位数,求个位,十位,百位 #include<stdio.h> main() { int a; printf("输入一个三位数"); scanf("%d",&a); printf("个位是:%d\n十位是:%d\n百位是%d\n",a/100,a%100/10,a%10); } 2.输入一个 阅读全文
posted @ 2021-11-30 14:33 AI-ccc 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,统计字符串中大写字母的个数#include <stdio.h> main() { char str[80]; int i=0; int cnt=0; printf("请输入你的字母:"); gets(str); while ( str[i]!=0 ) { if ( str[i]>='A 阅读全文
posted @ 2021-11-29 22:05 AI-ccc 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 编写程序,统计字符串中大写字母的个数 #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++; 阅读全文
posted @ 2021-11-25 21:09 AI-ccc 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 定义一个含有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 阅读全文
posted @ 2021-11-16 21:12 AI-ccc 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,求1-1/2+1/3-1/4+……+1/99-1/100的值 #include<stdio.h> main() { int s; double sum,t,d; sum=1.0; d=2.0; s=1; while(d<=100) { s=(-1)*s; t=s*(1/d); sum= 阅读全文
posted @ 2021-11-16 21:04 AI-ccc 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1.输出正三角 #include<stdio.h> main(){ int i,j; for(i=1;i<=6;i++){ for(j=1;j<=i;j++){ printf("*"); } printf("\n"); } 2.输出倒三角 #include<stdio.h> main(){ int 阅读全文
posted @ 2021-11-16 20:55 AI-ccc 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 编写程序判断n是正数还是负数。 #include<stdio.h> main() { int n; printf("输入一个整数:\n"); scanf("%d",&n); if(n>0) printf("%d是正数!\n"); else if(n==0) printf("%d既不是正数,也不是负数 阅读全文
posted @ 2021-10-31 21:33 AI-ccc 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1. #include<stdio.h> main() { int mark; printf("输入学生的分数(0-100):\n"); scanf("%d”,&mark); switch(mark/10) { case 10: //与case9:共用一条语句 case 9:printf("A\n" 阅读全文
posted @ 2021-10-26 10:57 AI-ccc 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 编写程序,使用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-17 21:04 AI-ccc 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 编写程序,定义两个整型变量,赋值并输出。 #include<stdio.h> main() { int a=2; int b=6; printf("%d%d\n",a,b); 2.编写程序,定义一个单精度和一个双精度的变量,赋值并输出。 #include<stdio.h> main() { floa 阅读全文
posted @ 2021-10-13 21:22 AI-ccc 阅读(25) 评论(0) 推荐(0) 编辑