👤

Se consideră 2 fişiere, nu ştim câte numere au, sa se verifice daca sânt identice (au aceleaşi numere).
In c++

Va rog, dau coroana!!


Răspuns :

#include <iostream>

#include <fstream>

using namespace std;


int main()

{

   int x, y, ok=1;

   ifstream f;

   ifstream o;

   f.open("fisier1.in");

   o.open("fisier2.in");

   while(f>>x)

   {

   o>>y;

   if(x!=y) {

   ok=0;

   break;

   }

   }

   if(ok==1) cout<<"Fisiere identice";

   else cout<<"Fisierele nu sunt identice";

   f.close();

  o.close();

   return 0;

}