This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//803 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int i = 0, a = 0, b = 0, c = 0;//宣告整數變數 | |
int tk;//宣告tk是一個整數 | |
while (i<10) {//i從0開始到9共有10票 | |
printf("(1)小蔡\n(2)小王\n(3)小史\n請你投票:");//列印 | |
scanf("%d", &tk);//輸入整數 &為取址 | |
if (tk == 1)a++;//如果投1號,a+1 | |
else if (tk == 2)b++;//如果投2號,b+1 | |
else if (tk == 3)c++;//如果投3號,c+1 | |
printf("\n小蔡得票數%d\n小王得票數%d\n小史得票數%d\n\n", a, b, c);//列印 | |
i++; | |
} | |
system("PAUSE");//停住等待使用者按下任意一個按鍵 | |
return 0;//跳出 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment