//猜数字
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int menu(){
//输出菜单
int chioce;
printf("-----------------\n");
printf(“1.开始游戏\n”);
printf(“2.结束游戏\n”);
printf("-----------------\n");
printf(“请输入你的选择:”);
scanf("%d",&chioce);
return chioce;
}
void Game(){
int guess = rand() % 100 + 1;
while (1){
printf("请输入你猜测的数:");
int num = 1;
scanf("%d",&num);
if (num > guess){
printf("高了\n");
}
else if(num < guess){
printf("低了\n");
}
else{
printf("恭喜你猜对了!\n");
break;
}
}
}
int _main(){
srand((int)time(0));
while (1){
int chioce = menu();
if (chioce == 1){
Game();
}
else if(chioce == 2){
printf("goodbay\n");
break;
}
else{
printf("你的输入有误!\n");
}
}
system("pause");
return 0;
}
//水仙花数
#include <stdio.h>
#include <stdlib.h>
int __main(){
int a, b, c, d ;
printf(“水仙花数是:\n”);
for (d = 2;d < 999; d++){
a = d / 100;
b = d / 10 % 10;
c = d % 10;
if (d == aaa + bbb + ccc)
printf("%d\n",d);
}
system("pause");
return 0;
}
//输出***
#include <stdio.h>
#include <stdlib.h>
int ___main(){
int i , n;
for (n = 1; n <= 7; n++){
for (i = 1; i <= 2n - 1; i++){
printf("");
}
printf("\n");
}
for (n = 7; n >= 1; n–){
for (i = 1; i <= 2 * n - 1; i++){
printf("");
}
printf("\n");
}
system(“pause”);
return 0;
}
//输出sn=a+aa+aaa+aaaa+aaaa*a
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int _____main(){
int num, sn = 0 ,i, b = 1;
scanf("%d", &num);
for (i = 1; i <= 5; i++){
b = b * num;
sn = sn + b;
}
printf(“总和为%d\n”,sn);
system(“pause”);
return 0;
}