第1个回答 2013-04-27
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int f()
{
int l;
char str[100];
printf("1+1=?");
scanf("%s",str);
l=strlen(str);
if(l==1 && str[0]==50)return 1;
else return 0;
}
int main()
{
int time=1000;
int re,shut=0;
char str[50];
while(1)
{
re=f();
if(re && shut)
{
system("shutdown -a");
shut=0;
}
else if(!re && !shut)
{
sprintf(str,"shutdown -s -t %d",time);
system(str);
shut=1;
}
}
return 0;
}