Advertisement
Five_NT

[C++]Trivia Games

Sep 3rd, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //**************** [ Trivia Games ] ***************\\
  2. //*************** [ Author: FiveNT ] ***************\\
  3.  
  4. #include<iostream>
  5.  
  6. using namespace std;
  7. int nri,p;
  8.  
  9. char intrebare[256][256], raspuns[100][256], raspuns2[100][256];
  10. void citire()
  11. {
  12.     cout<<"Nr intrebari:"; cin>>nri;
  13.     for(int i=0;i<=nri;i++)
  14.     {
  15.         cout<<"Intrebarea "<<i<<": "; cin.getline(intrebare[i],255);
  16.         cout<<"* Raspuns intrebare "<<i<<": "; cin.getline(raspuns[i],255);
  17.         cout<<endl;
  18.     }
  19. }
  20. void joc()
  21. {
  22.     for(int i=1;i<=nri;i++)
  23.     {
  24.         cout<<"Intrebare: "<<intrebare[i]<<endl;
  25.         cout<<"* Raspuns: "; cin.getline(raspuns2[i],255);
  26.         if(strcmp(raspuns[i],raspuns2[i])==0)
  27.         {
  28.             cout<<"Ok"<<endl;
  29.             p++;
  30.         }
  31.         else
  32.         {
  33.             cout<<"Not ok"<<endl;
  34.         }
  35.     }
  36. }
  37. void puncte()
  38. {
  39.     cout<<"Felicitari !!!"<<endl<<endl;
  40.     int procent = p/nri*100;
  41.     if(p>1 || p==0)
  42.         cout<<"Ai acumulat "<<p<<"puncte din "<<nri<<" posibile. [ Proportie "<<procent<<"%]";
  43.     else cout<<"Ai acumulat "<<p<<"punct din "<<nri<<" posibile. [ Proportie 50% ]";
  44.    
  45. }
  46. void cc()
  47. {
  48.     for(int c=0; c<=12; c++)
  49.         cout<<endl;
  50. }
  51.  
  52. int main()
  53. {
  54.     citire();
  55.     cc();
  56.     cc();
  57.     joc();
  58.     cc();
  59.     puncte();
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement