摘要: 1.猜数字#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int a,b,c; srand((unsigned)time(NULL)); a = rand(); printf("%d\n", a); b = 阅读全文
posted @ 2021-11-26 22:10 龙23 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序 #include<stdio.h> #include<string.h> void mainMenu(); void login(); void returnToMain(); void regist(); void shuixianhua(); main() { mainMenu() 阅读全文
posted @ 2021-11-26 21:50 龙23 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 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++ 阅读全文
posted @ 2021-11-23 09:59 龙23 阅读(6) 评论(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("%.2f 阅读全文
posted @ 2021-11-16 22:09 龙23 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1.输出直角三角形。 #include<stdio.h> main() { int i,j; for(i=1;i<=5;i++){ for(j=1;j<=i;j++){ printf("*"); } printf("\n"); } } 2.输出倒等腰三角形。 #include<stdio.h> ma 阅读全文
posted @ 2021-11-09 10:56 龙23 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,使用while语句求和sum=1+3+5+…+21。 #include<stdio.h> main() { int i=1,sum=0; while(i<=21){ sum=sum+i; i+=2;} printf("请输出%d",sum); } 2.编写程序,使用while语句求和1 阅读全文
posted @ 2021-11-02 11:17 龙23 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序判断n是正数还是负数。 #include<stdio.h> main() { int n; printf("请输入一个数n:\n"); scanf("%d",&n); if(n>0){ printf("这是正数"); }else if(n==0){ printf("既不是正数也不是负数" 阅读全文
posted @ 2021-10-30 12:41 龙23 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 1.例4-8 分数转成等级 switch。 #include<stdio.h> main() { int mark; printf("请输入学生的分数(0-100):\n"); scanf("%d",&mark); switch(mark/10) { case 10: case 9:printf(" 阅读全文
posted @ 2021-10-26 11:23 龙23 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 编写程序,判断一个数n是正数还是负数。 #include<stdio.h> main() { double x; scanf("%lf",&x); if(x>0){ printf("正数"); }else if(x=0){ printf("既不是正数,也不是负数"); }else{ printf(" 阅读全文
posted @ 2021-10-19 11:46 龙23 阅读(21) 评论(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); 阅读全文
posted @ 2021-10-15 21:41 龙23 阅读(15) 评论(0) 推荐(0) 编辑