摘要: 1.实现一个菜单,可以切换,可以返回主菜单。 #include<stdio.h> #include<string.h> void mainMenu(); void denglu(); void zhuce(); void shuixianhua(); void returnToMenu(); mai 阅读全文
posted @ 2021-12-08 17:16 嘉阡陌 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,统计字符串中大写字母的个数。 #include<stdio.h> main(){ char str[50]; int i=0; int length=0; gets(str); while(str[i]!='\0'){ if(str[i]>='A'&&str[i]<='Z') leng 阅读全文
posted @ 2021-12-08 17:14 嘉阡陌 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1定义一个含有8个储存单位的实型数组,从键盘上接收数据,然后逆序输出。 #include<stdio.h> main(){ int a[8]; int i; for(i=0;i<=7;i++) scanf("%d",&a[i]); for(i=7;i>=0;i--) printf("%d",a[i] 阅读全文
posted @ 2021-12-08 17:13 嘉阡陌 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 1.随机产生一个0-99的数,猜猜看, 如果大了,就提示大了点 小了就提示小了点 直到猜对为止。 #include <stdio.h> #include <stdlib.h> #include <time.h> int main(){ int a,n; srand((unsigned)time(NU 阅读全文
posted @ 2021-12-08 17:11 嘉阡陌 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 1.输出以下图形。 (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> main(){ int 阅读全文
posted @ 2021-12-08 17:10 嘉阡陌 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,使用while语句求和sum=1+3+5+7+……+21. #include<stdio.h> main(){ int i=1,sum=0; while(i<=21){ if(i%2!=0) sum+=i; i++; } printf("sum=%d\n",sum); } 2.编写程序 阅读全文
posted @ 2021-12-08 17:08 嘉阡陌 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序判断n是正数还是负数。 #include<stdio.h> main(){ float n; printf("输入一个数\n"); scanf("%f",&n); if(n>0) printf("%f是正数"); else if(n==0) printf("%f既不是正数也不是负数"); 阅读全文
posted @ 2021-12-08 17:06 嘉阡陌 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 1.使用switch-case语句编写代码。 #include<stdio.h> main(){ int mark; printf("输入学生成绩(0-100):\n"); scanf("%d",&mark); switch(mark/10){ case 10: case 9:printf("A\n 阅读全文
posted @ 2021-12-08 17:04 嘉阡陌 阅读(22) 评论(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-18 21:04 嘉阡陌 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,输入“我爱学习C语言!”。 #include<stdio.h> main(){ printf("我爱学习C语言!\n"); } 2.分行输出自己的专业和姓名 #include<stdio.h> main(){ printf("计算机科学与技术\n向涛\n"); } 3.用*号输出C的图 阅读全文
posted @ 2021-10-07 14:43 嘉阡陌 阅读(16) 评论(0) 推荐(0) 编辑