摘要: 1.实现一个菜单 可以切换 ,可以返回主菜单 主菜单 1.登录 2.注册 3.输出水仙花数 4.退出程序 请选择: 选择后实现对应的功能 #include<stdio.h> #include <string.h> void login(); void mainMenu(); void rigist( 阅读全文
posted @ 2021-11-26 19:57 浅殇之城 阅读(21) 评论(0) 推荐(0)
摘要: 1.猜数字,猜错提示,猜对结束。 #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int a,b,c; srand((unsigned)time(NULL)); a = rand(); printf("%d\ 阅读全文
posted @ 2021-11-25 22:51 浅殇之城 阅读(17) 评论(0) 推荐(0)
摘要: 1.用循环机构求字符串长度。 #include<stdio.h> main(){ char cs[20]; int i=0,lenght=0; gets(cs); puts(cs); while(cs[i++]!='\0') lenght++; printf("字符串的长度为:%d\n",lengh 阅读全文
posted @ 2021-11-25 22:49 浅殇之城 阅读(20) 评论(0) 推荐(0)
摘要: 1.定义一个含有8个储存单元的实型数组,从键盘上接收数,然后逆向输出。 #include<stdio.h> main(){ int i; double a[8]; printf("请输入8个实数\n"); for(i=0;i<=7;i++){ scanf("%lf",&a[i]); } for(i= 阅读全文
posted @ 2021-11-25 22:46 浅殇之城 阅读(15) 评论(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> main() { in 阅读全文
posted @ 2021-11-14 14:37 浅殇之城 阅读(18) 评论(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("sum=%d\n",sum); } 2.编写程序,使用while语句 阅读全文
posted @ 2021-11-02 10:16 浅殇之城 阅读(22) 评论(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("这是负数"); } } 2 阅读全文
posted @ 2021-10-30 23:32 浅殇之城 阅读(32) 评论(0) 推荐(0)
摘要: 1.编写程序,使用switch-case语句将输入的分数转换为相应的等级。 #include<stdio.h> main(){ int mark; printf("请输入学生的分数(0——100):\n"); scanf("%d",&mark); switch(mark/10) { case 10: 阅读全文
posted @ 2021-10-26 11:22 浅殇之城 阅读(31) 评论(0) 推荐(0)
摘要: 1.编写程序,判断一个数n是正数还是负数。 #include<stdio.h> main(){ int a; scanf("%d",&a); if(a>0) printf("这是正数"); else printf("这是负数"); } 2.编写程序,计算出租车的行驶距离与费用之间的关系。起步3km内 阅读全文
posted @ 2021-10-19 20:45 浅殇之城 阅读(15) 评论(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-16 12:25 浅殇之城 阅读(41) 评论(0) 推荐(0)