1
~cpp #include<iostream> #include<fstream> using namespace std; int main() { ifstream fin("input.txt"); int number; int floor; int people = 0; int in; int out; fin >> number; cout << number << "리 물." << endl; while(fin >> floor >> in >> out) { people = people + in - out; cout << " " << floor << " " << endl << in << "명 " << out << "명 내" << endl << people << "명 남" << endl << "**************************************************" << endl; } return 0; }?
~cpp #include<iostream> #include<fstream> using namespace std; int main() { ifstream fin("input.txt"); int number; int floor; int people = 0; int in; int out; int temp = 1; fin >> number; cout << number << "리 물." << endl; while(fin >> floor >> in >> out) { if(temp < floor) { while(temp+1 != floor) { temp++; cout << " " << temp << " " << endl << "**************************************************" << endl; } temp++; } else if(temp > floor) { while(temp-1 != floor) { temp--; cout << " " << temp << " " << endl << "**************************************************" << endl; } } people = people + in - out; cout << " " << floor << " " << endl << in << "명 " << out << "명 내" << endl << people << "명 남" << endl; if(people > 10) { cout << "\a." << endl << people - 10 << "명 내립." <<endl; people = 10; } cout << "**************************************************" << endl; } return 0; }