C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[8291] 이거 어째....... -.-; (냉무)
bluewing [bluewing] 1095 읽음    2001-06-16 19:42
김미진 님이 쓰신 글 :
: #include <iostream.h>
: #include <stdlib.h>
:
: struct gujo            //학생들의 자료를 입력할 구조체 선언
: {
:     char name[8];    //이름[영문8자, 한글4자]
:     int hak;        //학번
:     int sbj[3];        //과목점수[3과목 저장할 공간]
:     int total;        //합계
:     float avg;        //평균
: };
:
: void main(int argc, char *argv[])
: {
:     int num, i, j;            //int형 변수 선언 : 학생수 num, 반복문을 돌리기 위한 변수 i, j
:     gujo *std, temp;        //구조체 gujo형 변수 선언 : 포인터형 std변수, 평범한 temp변수
:
:     num=atoi(argv[4]);        //프로그램 시작할때 4번째로 입력한 학생수를 int형으로 바꿔서 num변수에 저장
:
:     std = new gujo[num];    //gujo형 std포인터변수의 메모리 공간을 학생수(num)의 갯수만큼 공간확보
:
:
:     //학생들의 자료입력
:     for(i=0;i<num;++i)        //0 ~ 학생수-1 까지 반복 ps.학생수가 3명이라도 번호는 0번부터 매기므로
:     {
:         cout << i+1 << "번 학생의 자료입력" << endl;
:
:         cout << "이름 입력:";
:         cin >> std[i].name;            //gujo형 std포인터변수의 [i]번 배열의 name맴버변수에 이름값 입력
:         cout << "학번 입력:";
:         cin >> std[i].hak;                            //위의 설명과 같고 hak맴버변수에 입력
:         cout << argv[1] << "과목의 점수 입력:";
:         cin >> std[i].sbj[0];                        //위와 동문
:         cout << argv[2] << "과목의 점수 입력:";
:         cin >> std[i].sbj[1];                        // ''
:         cout << argv[3] << "과목의 점수 입력:";
:         cin >> std[i].sbj[2];                        // ''
:
:         std[i].total = std[i].sbj[0]+std[i].sbj[1]+std[i].sbj[2];    //total맴버 변수에 각 과목의 값을 모두 더해서 넣는다.
:         std[i].avg = float(std[i].total)/3;            //avg맴버 변수 = 실수형(총점totla)/3
:
:         cout << "\n";                //보기 좋도록 한칸 띄움
:     }
:
:
:     //총점이 높은 순으로 다시 배열하는 반복문
:     for(i=0;i<num-1;++i)
:     {
:         for(j=i+1;j<num;++j)
:         {
:             if(std[i].total < std[j].total)        //두개의 총점을 비교해서...
:             {
:                 temp = std[i];        //
:                 std[i] = std[j];    //값을 서로 바꾼다.
:                 std[j] = temp;        //
:             }
:         }
:     }
:
:
:     //지금까지의 자료를 보기 좋게 나열하고 출력
:     cout << "  학번    이름";
:     cout.width(6);
:     cout << argv[1];
:     cout.width(6);
:     cout << argv[2];
:     cout.width(6);
:     cout << argv[3];
:     cout << "  총점  평균" << endl;
:    
:     for(i=0;i<num;++i)
:     {
:         cout.width(6);
:         cout << std[i].hak;
:         cout.width(8);
:         cout << std[i].name;
:         cout.width(6);
:         cout << std[i].sbj[0];
:         cout.width(6);
:         cout << std[i].sbj[1];
:         cout.width(6);
:         cout << std[i].sbj[2];
:         cout.width(6);
:         cout << std[i].total;
:         cout.width(6);
:         cout.precision(3);
:         cout << std[i].avg << endl;
:     }
: }
:
:

+ -

관련 글 리스트
8288 프로그램 짠건데요. 좀 다르고 쉽게 바꿔주셨으면해서요...월요일까지 꼭 부탁해요... 김미진 1235 2001/06/16
8292     Re:프로그램 짠건데요. 좀 다르고 쉽게 바꿔주셨으면해서요...월요일까지 꼭 부탁해요... 이경문 1120 2001/06/16
8291     이거 어째....... -.-; (냉무) bluewing 1095 2001/06/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.