1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
using namespace std;
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
int main() {
int CN=0, N1=0, N2=0, N3=0, N4=0, CN_1=0, N1_1=0, N2_1=0, N3_1=0, N4_1=0;
string line, line1;
ifstream myfile ("NB.txt");
ifstream myfile1 ("NB1.txt");
if (myfile.is_open())
{
ofstream secondoutput_11;
secondoutput_11.open ("11.txt");
for (int linenoq = 0; getline (myfile,line) && linenoq < 4; linenoq++){
myfile>>CN>>N1>>N2>>N3>>N4;
cout<<"linenoq : "<<linenoq<<endl;
myfile1.seekg(0, myfile1.beg);
for (int linenoq1 = 0; getline (myfile1,line1) && linenoq1 < 4; linenoq1++){
myfile1>>CN_1>>N1_1>>N2_1>>N3_1>>N4_1;
if (CN_1>CN){
cout<<"linenoq1 : "<<linenoq1<<endl;
if (N1==N1_1||N1==N2_1||N1==N3_1||N1==N4_1){
secondoutput_11<<CN<<" "<<CN_1<<" "<<N1<<endl;
}
if (N2==N1_1||N2==N2_1||N2==N3_1||N2==N4_1){
secondoutput_11<<CN<<" "<<CN_1<<" "<<N2<<endl;
}
if (N3==N1_1||N3==N2_1||N3==N3_1||N3==N4_1){
secondoutput_11<<CN<<" "<<CN_1<<" "<<N3<<endl;
}
if (N4==N1_1||N4==N2_1||N4==N3_1||N4==N4_1){
secondoutput_11<<CN<<" "<<CN_1<<" "<<N4<<endl;
}
}
}
}
secondoutput_11.close();
}
else cout << "Unable to open file"<<endl;
}
| |