摘要: 猜数字: 随机产生一个0-99的数,猜猜看 如果大了 就提示大了点 如果小了 就提示小了点 直到猜对为止 #include <stdio.h> #include <stdlib.h> #include <time.h> main(){ int x,guess; srand((unsigned int 阅读全文
posted @ 2021-11-12 18:26 顾白白 阅读(6) 评论(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"); } 输出倒三角 #include<stdio.h> main(){ int i 阅读全文
posted @ 2021-11-09 10:10 顾白白 阅读(27) 评论(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-05 19:26 顾白白 阅读(28) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>main(){int n;printf("输入一个整数:\n");scanf("%d",&n);if(n>0)printf("%d是正数!\n",n);elseif(n==0)printf("%d既不是正数,也不是是负数!\n",n);elseprintf("%d是 阅读全文
posted @ 2021-10-30 22:30 顾白白 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 1.教材p52 例4-8 分数转成等级 switch #include<stdio.h> main() { int mark; printf("请输入学生的分数(0-100):\n"); scanf("%d",&mark); switch(mark/10) { case 10: case 9:pri 阅读全文
posted @ 2021-10-30 22:21 顾白白 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 编写程序,判断一个数n是正数还是负数. include<stdio.h> main() { float n; scanf("%f",&n); if(n>0) {printf("正数\n");} else if (n==0) {printf("0既不是正数,也不是负数!\n");} else prin 阅读全文
posted @ 2021-10-24 21:17 顾白白 阅读(4) 评论(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<std 阅读全文
posted @ 2021-10-18 23:23 顾白白 阅读(24) 评论(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-15 13:15 顾白白 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-10-04 22:34 顾白白 阅读(16) 评论(0) 推荐(0) 编辑