[問題] 自己寫的亂數程式碼 有地方錯誤沒辦法執行
打完後按執行 卻沒辦法編譯 一直顯示程式碼有地方錯誤
所以PO上來跟大家討論
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string>
void aaaa();
int main()
{
char str[5];
while(1)
{
printf("輸入OPEN產生,輸入CLOSE結束此程式:");
scanf("%s",&str);
if((str=="OPEN")||(str=="open"))
aaaa();
else if((str=="CLOSE")||(str=="close"))
break;
else printf("您輸入錯誤,請重新輸入。\n");
}
system("pause");
return 0;
}
void aaaa()
{
int x;
srand(time(NULL));
x=(rand()%5)+1;
switch(x)
{
case 1:
printf("A");
break;
case 2:
printf("B");
break;
case 3:
printf("C"); break;
case 4:
printf("D");
break;
default:
printf("E");
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.115.217.2
→
09/02 20:40, , 1F
09/02 20:40, 1F
→
09/02 21:08, , 2F
09/02 21:08, 2F
→
09/04 17:36, , 3F
09/04 17:36, 3F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章