摘要:
1.实现一个菜单 可以切换 ,可以返回主菜单 主菜单 1.登录 2.注册 3.输出水仙花数 4.退出程序 请选择: 选择后实现对应的功能 #include <stdio.h> void mainMenu(); void login(); void returnToMain(); void regis 阅读全文
摘要:
1.用循环求字符串长度 #include<stdio.h> #include<string.h> main(){ int i=0; char str[50]="wo ai c yuyan"; while(str[i]!='\0'){ i++; } printf("%d\n",i); } 2.编写程序 阅读全文
摘要:
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("%f", 阅读全文
摘要:
1.猜数字:随机产生一个0-99的数,猜猜看。(如果大了 ,就提示大了点;如果小了 , 就提示小了点;直到猜对为止。) #include<stdio.h>#include<stdlib.h>#include<time.h>main(){ int x,guess; srand((unsigned in 阅读全文
摘要:
1.输出以下图形。 * ** *** **** ***** #include<stdio.h> main(){ int i,j; for(i=1;i<=5;i++){ for(j=1;j<=i;j++){ printf("*"); } printf("\n"); } } 2.输出以下图形。 **** 阅读全文
摘要:
1.编写程序,使用while语句求和sum=1+3+5+…+21。 #include<stdio.h> main(){ int i=1,sum=0; while(i<=21){ sum+=i; i++; } printf("和是%d\n",sum); } 2.编写程序,使用while语句求和sum= 阅读全文
摘要:
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既不是正数,也不 阅读全文
摘要:
1.分数转成等级。(用switch结构) #include<stdio.h>main(){ int mark; printf("输入分数:\n"); scanf("%d",&mark); switch(mark/10) { case 10: case 9:printf("A\n");break; c 阅读全文
摘要:
1.编写程序,判断一个数n是正数还是负数。 #include<stdio.h> main(){ float n; scanf ("%f",&n); if(n>0) printf("正数!\n"); else if(n==0) printf("0既不是正数,也不是负数!\n"); else print 阅读全文
摘要:
1.编写程序,定义两个整型变量,赋值并输出。 #include<stdio.h>main(){ int a=2; int b=6; printf("%d%d\n",a,b);} 2.编写程序,定义一个单精度和一个双精度的变量,赋值并输出。#include<stdio.h>main(){ float 阅读全文