Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iostream>
- using namespace std;
- class Esercizio
- {
- fstream File1,File2,File3;
- string InputProb, InputSol;
- int dim1, dim2;
- public:
- Esercizio(){};
- ~Esercizio(){};
- void Avvia()
- {
- File1.open("Problema.txt", ios::in);
- File2.open("Soluzione.txt",ios::in);
- File3.open("Esito.txt", ios::out);
- while(!File1.eof()||!File2.eof())
- {
- int i=0;
- int j=0;
- int dim1,dim2;
- getline( File1,InputProb);
- //File1>>InputProb;
- getline(File2, InputSol);
- //File2>>InputSol;
- dim1=InputProb.length();
- dim2=InputSol.length();
- for(i=0;i<dim1+1;i++)
- {
- if(InputProb[i]=='<')
- {
- if(InputProb[i]!=InputSol[j+1]||InputSol[j]>InputSol[j+2])
- {
- File3<<"Sol Sbagliata"<<endl;
- cout<<"Sol Sbagliata"<<endl;
- i=dim1+1;
- }
- j=j+2;
- }
- else if(InputProb[i]=='>')
- {
- if(InputProb[i]!=InputSol[j+1]||InputSol[j]<InputSol[j+2])
- {
- File3<<"Sol Sbagliata"<<endl;
- cout<<"Sol Sbagliata"<<endl;
- i=dim1+1;
- }
- j=j+2;
- }
- else
- {
- File3<<"Sol Corretta"<<endl;
- cout<<"Sol Corretta"<<endl;
- i=dim1+1;
- }
- }
- }
- File1.close();
- File2.close();
- File3.close();
- }
- };
- int main()
- {
- Esercizio test;
- test.Avvia();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement