Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. bool** genmat(){
  5.     bool** test=new bool*[10];
  6.     for(int i=0;i<10;++i){
  7.         test[i]=new bool[4];
  8.     }
  9.     return test;
  10. }
  11.  
  12. void assmat(bool** mat){
  13.     for(int i=0;i<10;++i){
  14.         for(int j=0;j<4;++j){
  15.             mat[i][j]=false;
  16.         }
  17.     }
  18. }
  19.  
  20. void genrispcorr(bool** mat){
  21.     for(int i=0;i<10;++i){
  22.         int a=rand()%3;
  23.         mat[i][a]=true;
  24.     }
  25. }
  26.  
  27. void genrispconc(bool** mat, int o){
  28.     int somma=0;
  29.     std::cout<<"Quiz concorrente "<<o<<"\t"<<std::endl;
  30.     for(int i=0;i<10;++i){
  31.         int k=0;
  32.         int a=rand()%3;
  33.         if(mat[i][a]==true){
  34.             k=3;
  35.             std::cout<<"Risposta corretta: 3 punti"<<std::endl;
  36.         }
  37.         else{
  38.             k=-1;
  39.             std::cout<<"Risposta errata: -1 punto"<<std::endl;
  40.         }
  41.         somma+=k;
  42.     }
  43.     std::cout<<"Punteggio totale: "<<somma<<"\t\t"<<std::endl;
  44. }
  45.  
  46.  
  47. int main(){
  48.     for(int i=0;i<7;++i){
  49.         bool** test=genmat();
  50.         assmat(test);
  51.         srand(time(NULL));
  52.         genrispcorr(test);
  53.         genrispconc(test,i);
  54.     }
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement