学C语言真的太太太锻炼逻辑思考了
今天的学习主要以代码为主,课上讲了好多练习题拿几个印象深刻的放这里分享一下
数一下1-100中有几个数字9
#include
int main()
{
int i = 0;
int count = 0;
for (i = 1; i
输出乘法口诀表
#include
int main()
{
服务器托管网int i = 0;
int j = 0;
for(i = 1; i
猜数字游戏
这玩意我是感觉太绕太绕了,还得多看几遍
#include
#include
#include
#include
void menu()
{
printf("******************************n");
printf("***** 1.Play 0.Exit *****n");
printf("******************************n");
}
void game()
{
int ret = 0;
int guess;
ret = rand()%100+1;//生成1-100的随机数
//printf("%dn",ret);
while (1)
{
printf("请猜数字n");
scanf("%d", &guess);
if (guess ret)
{
printf("猜大了n");
}
if (guess == ret)
{
printf("恭喜你,猜对了!n");
break;
}
}
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL));//拿时间戳来设置生成起始点
do
{
menu();
printf("请选择:>");
scanf("%d", &input);
switch (input)
{
case 1:
game();
break;
case 0:
printf("退出游戏n");
break;
d服务器托管网efault:
printf("输入无效,请重新输入!n");
break;
}
} while (input);
return 0;
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
Free Edition: http://download.ccleaner.com/ccsetup545.exe Portable: http://www.ccleaner.com/ccleaner/download/portable/downloadf…