Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a=0, b=0, c=0, people=0, choose;
- do
- {
- printf("Enter choose (a=1, b=2,c=3,-1 to end): ");
- scanf("%d", &choose);
- switch(choose)
- {
- case 1:
- a++; people++; break;
- case 2:
- b++; people++; break;
- case 3:
- c++; people++; break;
- case -1:
- break;
- default:
- printf("Please enter a valid number.\n");
- }
- } while (choose != -1);
- printf("a\tb\tc\tpeople\n%d\t%d\t%d\t%d\n", a, b, c, people);
- if (a>b && a>c)
- printf("The city leader is a\n");
- else if (b>a && b>c)
- printf("The city leader is b\n");
- else if (c>a && c>b)
- printf("The city leader is c\n");
- else
- printf("This city has no leader.\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement