求解!!无语,输一个char print出来两遍。。。dev cpp c语言
#include<stdio.h>#include<stdlib.h>#include<string.h>#include"random.h"intmain(intarg...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "random.h"
int main(int argc, char *argv[])
{
Randomize();
char result[10],*word,guess[10];
int t,i,j,k,count=8,len,flag=0,sign;
t=RandomInteger(1,10);
switch(t){
case 1: word="kobe";len=4;break;
case 2: word="lebron";len=6;break;
case 3: word="tracy";len=5;break;
case 4: word="dwayne";len=6;break;
case 5: word="gilbert";len=7;break;
case 6: word="steve";len=5;break;
case 7: word="dwight";len=6;break;
case 8: word="michael";len=7;break;
case 9: word="larry";len=5;break;
default: word="grant";len=5;break;
}
printf("The word looks like this.");
for(i=0;i<len;i++){
result[i]='-';
printf("%c",result[i]);
}
for(i=0;i<8;i++){
printf("\nYou have %d guesses left.\nYour guess:",count);
guess[i]=getchar();
}
system("PAUSE");
return 0;
} 展开
#include <stdlib.h>
#include <string.h>
#include "random.h"
int main(int argc, char *argv[])
{
Randomize();
char result[10],*word,guess[10];
int t,i,j,k,count=8,len,flag=0,sign;
t=RandomInteger(1,10);
switch(t){
case 1: word="kobe";len=4;break;
case 2: word="lebron";len=6;break;
case 3: word="tracy";len=5;break;
case 4: word="dwayne";len=6;break;
case 5: word="gilbert";len=7;break;
case 6: word="steve";len=5;break;
case 7: word="dwight";len=6;break;
case 8: word="michael";len=7;break;
case 9: word="larry";len=5;break;
default: word="grant";len=5;break;
}
printf("The word looks like this.");
for(i=0;i<len;i++){
result[i]='-';
printf("%c",result[i]);
}
for(i=0;i<8;i++){
printf("\nYou have %d guesses left.\nYour guess:",count);
guess[i]=getchar();
}
system("PAUSE");
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询