Advertisement
nicb

EseFeroneLab2

Oct 7th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. class Esercizio
  10. {
  11.     fstream File1,File2,File3;
  12.     string InputProb, InputSol;
  13.     int dim1, dim2;
  14. public:
  15.     Esercizio(){};
  16.     ~Esercizio(){};
  17.  
  18.     void Avvia()
  19.     {
  20.         File1.open("Problema.txt", ios::in);
  21.         File2.open("Soluzione.txt",ios::in);
  22.         File3.open("Esito.txt", ios::out);
  23.         while(!File1.eof()||!File2.eof())
  24.             {
  25.                 int i=0;
  26.             int j=0;
  27.             int dim1,dim2;
  28.             getline( File1,InputProb);
  29.             //File1>>InputProb;
  30.             getline(File2, InputSol);
  31.             //File2>>InputSol;
  32.             dim1=InputProb.length();
  33.             dim2=InputSol.length();
  34.             for(i=0;i<dim1+1;i++)
  35.             {
  36.  
  37.                     if(InputProb[i]=='<')
  38.                         {
  39.                             if(InputProb[i]!=InputSol[j+1]||InputSol[j]>InputSol[j+2])
  40.                                 {
  41.                                     File3<<"Sol Sbagliata"<<endl;
  42.                                     cout<<"Sol Sbagliata"<<endl;
  43.                                     i=dim1+1;
  44.                                 }
  45.                             j=j+2;
  46.  
  47.                         }
  48.                         else if(InputProb[i]=='>')
  49.                         {
  50.                             if(InputProb[i]!=InputSol[j+1]||InputSol[j]<InputSol[j+2])
  51.                                  {
  52.                                     File3<<"Sol Sbagliata"<<endl;
  53.                                     cout<<"Sol Sbagliata"<<endl;
  54.                                     i=dim1+1;
  55.                                 }
  56.                             j=j+2;
  57.                         }
  58.                         else
  59.                         {
  60.                             File3<<"Sol Corretta"<<endl;
  61.                             cout<<"Sol Corretta"<<endl;
  62.                             i=dim1+1;
  63.                         }
  64.  
  65.  
  66.             }
  67.  
  68.             }
  69.         File1.close();
  70.         File2.close();
  71.         File3.close();
  72.     }
  73.     };
  74.  
  75.  
  76. int main()
  77. {
  78.    Esercizio test;
  79.    test.Avvia();
  80.    return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement