//12084569 ±Ç¹Îö #include //Ç¥ÁØÀÔÃâ·Â #include //ÆÄÀÏ ÀÔÃâ·Â ÇϱâÀ§ÇØ ofstream,ifstream fstream ¾²±âÀ§ÇØ #include //exit ¾²±âÀ§ÇØ #include //string ¾²±âÀ§ÇØ #include//setw ¿Í setprecision ÇÔ¼ö ¾²±âÀ§ÇÏ¿© using namespace std; enum RequestType { ONE = 1, TWO, THREE,FOUR, END };//¿­°ÅÇü µ¥ÀÌŸº¯¼ö ONE=1 TWO=2 THREE=3 FOUR =4 END =5 void outputLine( const string ,int,int,int );//Äֿܼ¡ Ãâ·ÂÇϱâ int getRequest(); bool shouldDisplay( int, double ); char name[30];//À̸§ int math;//¼öÇÐ int english;//¿µ¾î int computer;//ÄÄÇ»ÅÍ int main() { ofstream outClientFile ("clients.txt", ios::out );//ÆÄÀÏ¿¡Ãâ·Â °´Ã¼»ý¼ºÈÄ ÆÄÀÏÀÌ ¾øÀ¸¸é ¸¸µç´Ù. ¾Æ±Ô¸ÕÆ® 2°³ ÆÄÀÏÀ̸§°ú, ÆÄÀÏ¿¡ Ãâ·Â if ( !outClientFile ) // ÆÄÀÏÀÌ Á¦´ë·Î ¿­·ÁÀÖ´ÂÁö { cerr << "File could not be opened" << endl; //Á¦´ë·Î ¾È¿­·ÁÁö¸é ¿¹¿Üó¸® ¿¡·¯¸Þ¼¼ÁöÃâ·Â exit( 1 ); } cout << "Enter the Name, Math score, English score, Computer score."<< endl << "Enter end-of-file to end input.\n? "; while ( cin >> name >> math >> english>>computer) //ÆÄÀÏ¿¡ ÀԷ¹ޱâ { outClientFile << name << ' ' << math << ' ' <>name >> math >> english>>computer;//ÆÄÀÏÀÇ ³¡±îÁö µ¥ÀÌŸ¸¦ ÀоîµéÀÓ while ( !inClientFile.eof() ) //ÆÄÀÏÀÇ ³¡ÀÌ ¾Æ´Ï¶ó¸é { int total=math+english+computer; //ÃÑÇÕ double avg=total/3.0;//Æò±Õ if ( shouldDisplay( request, avg ) )// outputLine( name, math,english,computer ); inClientFile >> name >> math >> english>>computer;//ÆÄÀÏÀÇ ³¡±îÁö µ¥ÀÌŸ¸¦ ÀоîµéÀÓ }//¾ÈÂÊ¿ÍÀÏÁ¾·á inClientFile.clear();//ÆÄÀÏÀÌ EOF±îÁö °°´Ù¸é ÃʱâÈ­½ÃÅ´ inClientFile.seekg( 0 ); //ÆÄÀÏÀÇ Æ÷ÀÎÅͰ¡ ³¡±îÁö À̵¿µÈ°ÍÀ» ¸ÇóÀ½À¸·Î À̵¿½ÃÅ´ request = getRequest();//ÇÔ¼öÈ£Ãâ }//¹Ù±ùÂÊwhile Á¾·á cout << "End of run." << endl; return 0; } void outputLine( const string name,int math, int english, int computer ) { int total=math+english+computer; //ÃÑÇÕ double avg=total/3.0;//Æò±Õ cout << left << setw( 10 ) << "Name" << setw( 10 ) //¿ÞÂÊÁ¤·Ä 10ÀÚ¸®¾¿ ÇÒ´ç << "Math" << setw(10)<<"English"<> request;//ÀÔ·Â } while ( request < ONE && request > END ); return request; } bool shouldDisplay( int type, double avg )//Æò±ÕÀÇ ¹üÀ§½Ã ±×ÇØ´ç°ª ¸®ÅÏÇϱâ { if ( type == ONE && avg == 100 ) return true; if ( type == TWO && avg >=80 && avg <100 ) return true; if ( type == THREE && avg >=60 && avg <80) return true; if ( type == FOUR && avg <60 ) return true; return false; }