#include #include using namespace std; int main() { fstream myfile; myfile.open("barcode.in"); ofstream wfile("barcode.out"); int row; int col; char first[1000]; char second[1000]; char output; if (myfile.is_open()) { while (!myfile.eof()) { myfile >> row; myfile >> col; for (int j = 0; j < col; j++) { myfile >> first[j]; } for (int i = 1; i < row-1; i++) { for (int j = 0; j < col; j++) { myfile >> output; if (first[j] == output) { first[j] = output; } else { if (wfile.is_open()) { wfile << "NO"; wfile.close(); } return 0; } } if (wfile.is_open()) { wfile << "BUY"; wfile.close(); } return 0; } } } myfile.close(); }