摘要: 1.输入一个三位数,求个位,十位,百位 #include<stdio.h> main() { int a=857; int ge=a%10; int shi=a/10%10; int bai=a/100; printf("个位是%d,十位是%d,百位是%d",ge,shi,bai); } 2.输入一 阅读全文
posted @ 2021-11-30 10:21 徐赫彤 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 1.实现一个菜单,可以切换,可以返回主菜单。(主菜单:1.登录 2.注册 3.输出水仙花数 4.退出程序。请选择: 选择后实现对应的功能) #include <stdio.h> #include <string.h> void mainMenu(); void login(); void regis 阅读全文
posted @ 2021-11-28 13:13 徐赫彤 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 编写程序,输出“我爱学习c语言!”。 #include<stdio.h> main() { printf("我爱学习c语言!"); } 分行输出自己的专业和姓名 复制代码 #include<stdio.h> main() { printf("***************************** 阅读全文
posted @ 2021-11-24 13:27 徐赫彤 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 1.用循环结构求字符串的长度。 #include<stdio.h> main() { char str[80]; int i=0; int length=0; gets(str); puts(str); while(str[i++]!='\0') length++; printf("字符串的长度为: 阅读全文
posted @ 2021-11-24 13:22 徐赫彤 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1 定义一个含有八个存储单元的实型数据,从键盘上接收数,然后逆行输出。 #include<stdio.h> main() { int number[8]; int i; for(i=1;i<8;i++){ scanf("%d",&number[i]); } for(i=7;i>=1;i--){ pr 阅读全文
posted @ 2021-11-20 13:42 徐赫彤 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 猜数字: 随机产生一个0-99的数,猜猜看 如果大了 就提示大了点 如果小了 就提示小了点 直到猜对为止 #include <stdio.h> #include <stdlib.h> #include <time.h> main(){ int x,guess; srand((unsigned int 阅读全文
posted @ 2021-11-15 17:57 徐赫彤 阅读(20) 评论(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"); } } ******* ***** *** * 阅读全文
posted @ 2021-11-09 10:12 徐赫彤 阅读(8) 评论(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.编写程序,使用whil 阅读全文
posted @ 2021-11-05 22:01 徐赫彤 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序判断n是正数还是负数。 #include<stdio.h> main() { int n; printf("请输入一个整数:\n"); scanf("%d",&n); if(n>0) printf("%d是正数!\n",n); else if(n==0) printf("%d既不是正数, 阅读全文
posted @ 2021-10-29 20:50 徐赫彤 阅读(8) 评论(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-28 20:47 徐赫彤 阅读(12) 评论(0) 推荐(0) 编辑