수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

순차적탐색 질문입니다...ㅠㅜㅠㅜ

연하얀

2023.04.01

일단 먼저 소스부터 올려보께요,,,실행안되는 부분이 제가 질문하는 부분입니다..
#include iostream
#include fstream
#include iomanip
#include cstdlib
#include cctype
using namespace std;
const int STUNUM = 50;
const int EXAM = 6;
void input(ifstream& stuFile,int stu[][EXAM],int& index);
void writeStuu(int stu[][EXAM],int index);
int calAvrg(int stu[][EXAM],int count,int index);
int low(int stu[][EXAM],int count,int index);
/////
void search(int stu[][EXAM],int count, int index);
//////
void sort(int stu[][EXAM],int index);

int main()
{
ifstream stuFile;
stuFile.open(inputstu.TXT);
if(!stuFile)
{
cerr\aError k \n;
exit(100);
}
ofstream gradesFile;
gradesFile.open(stugrade.TXT);
if(!gradesFile)
{
cerr\aError k \n;
exit(102);
}

int stu[STUNUM][EXAM];
int index=0;
input(stuFile,stu,index);
sort(stu,index);

writeStuu(stu,index);
search(stu);
stuFile.close();
gradesFile.close();
return 0;
} //main
void input(ifstream& stuFile,int stu[][EXAM],int& index)
{
bool a = true;
while(a)
{
stuFile stu[index][0]
stu[index][1]
stu[index][2]
stu[index][3]
stu[index][4]
stu[index][5];
if(!stuFile)
a=false;
if(a)index++;
}
}

int calAvrg(int stu[][EXAM],int count,int index)
{
int avrg=0;
for(int i=0;iindex;i++)
{
avrg += stu[i][count];
}
avrg /= index;
return avrg;
}
int low(int stu[][EXAM],int count,int index)
{
int lownum = stu[0][count];
for(int i=0 ; iindex-1 ; i++)
{
if(stu[i+1][count] stu[i][count])
{
lownum = stu[i+1][count];
}
}
return lownum;
}

void sort(int stu[][EXAM],int index)
{
int temp[STUNUM][6];
for(int i=0;iindex;i++)
{
if(stu[i][0] stu[i+1][0])
{
for(int j=0;j6;j++)
{
temp[i][j]=stu[i+1][j];
stu[i+1][j]=stu[i][j];
stu[i][j]=temp[i][j];
}
}
}
}
///////////////////////////////////탐색함수
void search(int stu[][EXAM]){
int searchid;
cin searchid;
for(int i=0; i 50; i++)
{
if(stu[i][0] == searchid)
{
for(int j=0;j6;j++)
{
cout setw(5)stu[i][j];
}
cout endl;

}
else
cout 명단에 없습니다;

}
return;
}
////////////////////////////////////////////////////////////////////////////// 출력부분

void writeStuu(int stu[][EXAM],int index)
{
cout setw(5)Studentsetw(5)Quiz1setw(5)Quiz2
setw(5)Quiz3setw(5)Quiz4setw(5)Quiz5 endl;

for(int i=0;iindex;i++)
{
for(int j=0;j6;j++)
{
cout setw(5)stu[i][j];
}
cout endl;
}
cout setw(5)Lowendl;
cout setw(5)Score;

for(int e=1;e=5;e++)
{
cout setw(5) low(stu,e,index);
}

cout endl;
cout setw(5) Avrgendl;
cout setw(5)Score;

for(int d=1;d=5;d++)
{
cout setw(5) calAvrg(stu,d,index);
}
cout endl;
cout 아이디를 입력하세요 : ;
///////////
////////////////
return;
}

--------input.txt
1234 052 007 100 078 034
2134 090 036 090 077 030
3124 100 045 020 090 070
4532 011 017 081 032 077

질문?P질문드리겠습니다....먼저 문제는요,,,아이디를 입력받아서 그에 해당하는 아이디를 찾은 다음 그학생만 출력하는거든요,,

예를 들면
아이디를 입력하세요: 2134
2134 090 036 090 077 030

이런 식입니다...탐색하는 함수를 어떻게 하는지 모르겠네요,,,수정 부탁드릴게요,,,다른 부분은 정상으로 되는거기때문에

아이디 입력받아서 출력하는 부분만 한번 봐주시면 됩니다...감사합니다..

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2699518 javaScript중복체크 하는법좀.. 알려주세요 (3) 비 2025-06-26
2699495 이런 탭메뉴를 뭐라고 해야 하는지 모르겠네요 (1) 들빛 2025-06-26
2699380 메뉴가 계단식으로 나타나요.. ㅠ.ㅠ (5) 스릉흔다 2025-06-25
2699354 영문 웹폰트 관련 질문입니다!!! (1) 치킨마루 2025-06-25
2699329 윈도우 미디어 플레이어 URL 질문!!! (1) 제철 2025-06-25
2699296 동영상 배경 질문드려요!!!!!!!!!!!!!! 핫파랑 2025-06-24
2699214 position:fixed 에 대한 질문입니다.. (7) 사이 2025-06-24
2699183 제이쿼리 이미지 슬라이드 위치값 수정 초엘 2025-06-23
2699153 테마[ADORABLE]에서 페이지생성시 하위페이지는 2개밖에 안되나요? 흰여울 2025-06-23
2699129 네이버 블로그 또는 사이트의 글을 불러오기 갤원 2025-06-23
2699070 탭메뉴처럼 셀렉트 박스를 이용해서 내용을 출력할 수 있는 방법이 있을까요. (3) 큰꽃늘 2025-06-22
2699016 인터넷이 안되는 환경에서 validator설치방법 (3) 은송이 2025-06-22
2698988 대체 C++ 6.0 exe 아이콘은 어떻게 넣는건가요? 외국녀 2025-06-22
2698960 음성파일을 embed로 작업했는데..웹 표준코딩으로 변경하려면 어떻게 해야하나요? (1) 잎새 2025-06-21
2698932 메뉴목록 풍선창 만들기 html (2) 하늘이 2025-06-21
2698901 http://www.zeitgeistbot.com/ 이 사이트처럼 움직이는 효과를 무엇이라고 하나요? 누림 2025-06-21
2698876 table width값 크로스브라우징에 대한 문의 (2) 볼수록매력 2025-06-21
2698849 c언어 질문. (3) 아름나 2025-06-20
2698823 setInterval 이벤트 제거 하려면... 가온길 2025-06-20
2698796 이 오류를 이해를 못하겠어요 Addicted 2025-06-20
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com