Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created March 27, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/448837ad417187c271123930b1cbd55d to your computer and use it in GitHub Desktop.
Save ruyut/448837ad417187c271123930b1cbd55d to your computer and use it in GitHub Desktop.
//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