Advertisement
Kawsar_Hossain

Vote poll

Sep 29th, 2020
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. queue<int>line[3];
  6. int waiting[4], cnt[4][100], n, x, total[100];
  7. vector<string>name;
  8. void stand_In_Line(){
  9. system("cls");
  10. system("Color 9");
  11. cout << "HOW MANY PEOPLE WENT TO GIVE VOTE : ";
  12. int a;
  13. cin>>a;
  14. cout << "Which Line They Choose : ";
  15. int b;
  16. cin>>b;
  17. waiting[b-1]+=a;
  18. }
  19. void cast_Vote(){
  20. system("cls");
  21. system("Color 1");
  22. cout<<"Enter The Line Number Of The Voter : ";
  23. int a;
  24. cin>>a;
  25. if(!waiting[a]){
  26. cout<<"Sorry, the line is empty 🙁 \n";
  27. return;
  28. }
  29. int i=1;
  30. for(auto x:name) cout<<"To Vote For "<<x<<" Press "<<i++<<"\n";
  31. int b;
  32. cin>>b;
  33. cnt[a][b]++;
  34. waiting[a]--;
  35. total[b]++;
  36. }
  37. void display(){
  38. system("Color 8");
  39. int i=1;
  40. 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";
  41. for(int i=1; i<4; i++) cout<<waiting[i]<<" Voters Are Waiting In Line "<<i<<"\n";
  42. }
  43. void pre(){
  44. system("Color 12");
  45. cout<<"Enter Total Number of Contestant: ";
  46. cin>>n;
  47. cout<<"Enter Their Names\n";
  48. for(int i=1; i<=n; i++){
  49. cout<<i<<"# ";
  50. string t;
  51. cin>>t;
  52. name.push_back(t);
  53. }
  54. }
  55. int main(){
  56. if(!x)pre();
  57. system("Color 5");
  58. cout << "1. ADD NEW VOTER\n";
  59. cout << "2. ENTER FOR VOTE\n";
  60. cout << "3. DISPLAY CURRENT LIST\n";
  61. cout << "0. EXIT \n";
  62. cin>> x;
  63. switch(x){
  64. case 1:
  65. stand_In_Line();
  66. break;
  67. case 2:
  68. cast_Vote();
  69. break;
  70. case 3:
  71. display();
  72. break;
  73. case 0:
  74. cout << "THANKS for VOTING\n";
  75. exit(1);
  76. default:
  77. cout << "OPPS! TRY AGAIN!";
  78. main();
  79. }
  80. if(x!=0)main();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement