Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<stdio.h>
- #include<stdlib.h>
- using namespace std;
- queue<int>line[3];
- int waiting[4], cnt[4][100], n, x, total[100];
- vector<string>name;
- void stand_In_Line(){
- system("cls");
- system("Color 9");
- cout << "HOW MANY PEOPLE WENT TO GIVE VOTE : ";
- int a;
- cin>>a;
- cout << "Which Line They Choose : ";
- int b;
- cin>>b;
- waiting[b-1]+=a;
- }
- void cast_Vote(){
- system("cls");
- system("Color 1");
- cout<<"Enter The Line Number Of The Voter : ";
- int a;
- cin>>a;
- if(!waiting[a]){
- cout<<"Sorry, the line is empty 🙁 \n";
- return;
- }
- int i=1;
- for(auto x:name) cout<<"To Vote For "<<x<<" Press "<<i++<<"\n";
- int b;
- cin>>b;
- cnt[a][b]++;
- waiting[a]--;
- total[b]++;
- }
- void display(){
- system("Color 8");
- int i=1;
- for(auto x:name) cout<<"Total Vote For "<<x<<" = "<<total[i]<<"[Line 1:"<<cnt[1][i]<<"; Line 2:"<<cnt[2][i]<<"; Line 3:"<<cnt[3][i++]<<"]\n";
- for(int i=1; i<4; i++) cout<<waiting[i]<<" Voters Are Waiting In Line "<<i<<"\n";
- }
- void pre(){
- system("Color 12");
- cout<<"Enter Total Number of Contestant: ";
- cin>>n;
- cout<<"Enter Their Names\n";
- for(int i=1; i<=n; i++){
- cout<<i<<"# ";
- string t;
- cin>>t;
- name.push_back(t);
- }
- }
- int main(){
- if(!x)pre();
- system("Color 5");
- cout << "1. ADD NEW VOTER\n";
- cout << "2. ENTER FOR VOTE\n";
- cout << "3. DISPLAY CURRENT LIST\n";
- cout << "0. EXIT \n";
- cin>> x;
- switch(x){
- case 1:
- stand_In_Line();
- break;
- case 2:
- cast_Vote();
- break;
- case 3:
- display();
- break;
- case 0:
- cout << "THANKS for VOTING\n";
- exit(1);
- default:
- cout << "OPPS! TRY AGAIN!";
- main();
- }
- if(x!=0)main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement