정렬된상태에서 아이디까지 추가해서 출력하고싶은데요;ㅣ;
권애교
아래소스를 실행시키면 제가 coin이라고 지정한 뒤에 숫자만 전부 출력이 되요 오름차순으로.
근데 여기에 앞에 아이디를 같이 연동시켜서 출력하고싶은데 이것좀알려주세요..ㅠㅠㅠ
#includestdio.h
#includestdlib.h
#includestring.h
#includesys/types.h
#includesys/stat.h
#includeunistd.h
#define MAX 100
typedef struct{
char id[20],pwd[20],coin[5];
}GAME;
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void bubbleSort(int a[], int n)
{
int i,j;
for(i=2;in;i+=3){
for(j=5;jn;j+=3){
if(a[j-3]a[j]){
swap(&a[j-3],&a[j]);
}
}
}
}
void printList(int a[], int n)
{
int i;
for(i=2;in;i+=3){
printf(%d ,a[i]);
printf(\n);
}
}
int main(void){
FILE *fd;
char buffer[1024], *input[100],*input_2;
int i=0;
int j,q[MAX];
int a[MAX],b;
GAME game[MAX];
fd= fopen(tajja.data,r);
while(!(feof(fd)))
{
fscanf(fd, %s, buffer);
}
input_2 = strtok(buffer,:);
while(input_2 != NULL){
input[i]=input_2;
i++;
input_2=strtok(NULL,:);
}
for(j=0;ji;j+=3)
{
strcpy(game[j].id,input[j+0]);
strcpy(game[j].pwd,input[j+1]);
strcpy(game[j].coin,input[j+2]);
printf(☞%s☜===☞%s☜===☞%s☜\n,game[j].id,game[j].pwd,game[j].coin);
}
printf(\n 정렬전\n\n);
int c = 0;
for(j=0;ji;j++){
printf(%s ,input[j]);
q[c] = atoi(input[j]);
c++;
}
printf(\n);
bubbleSort(q,c);
printf(\n정렬후:\n);
printList(q,c);
fclose(fd);
return 0;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694503 | 프로그램 연산 후 바로 종료되는 현상 (6) | Judicious | 2025-05-11 |
2694450 | while문질문입니다. (1) | 허리품 | 2025-05-11 |
2694420 | C언어 질문할게요(유니코드,자료형,버퍼,캐스트연산자) | 은새 | 2025-05-11 |
2694370 | 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 | 들찬 | 2025-05-10 |
2694339 | putchar()의 괄호 안에 int c=10;로 전에 선언된 c를 넣으면 안되는 이유에서 제가 생각한 것이 그 이유가 되는지 확인하고 싶습니다. (3) | 미르 | 2025-05-10 |
2694316 | 이 코드 어디가 잘못되었는지 고수분들 ㅠㅠ (2) | 나빛 | 2025-05-10 |
2694285 | 언어 공부하는 과정 좀 추천해주세요! (1) | 아빠몬 | 2025-05-09 |
2694258 | 카운터.. 질문입니다. (4) | 하늘빛눈망울 | 2025-05-09 |
2694229 | 단순한 질문이요 (8) | 여름 | 2025-05-09 |
2694202 | 용돈을 가지고 할 수 있는 일을 여러가지로 출력하는 방법 좀 알려주세요! (2) | 미나 | 2025-05-09 |
2694145 | 화면깜빡임을 없애고 싶은데요... (1) | 어서와 | 2025-05-08 |
2694069 | unsigned 질문입니다. | 힘차 | 2025-05-07 |
2694012 | 전공 비전공자 개발자 (10) | 말글 | 2025-05-07 |
2693984 | 오버로딩이 무엇인가요? (2) | 헛매질 | 2025-05-07 |
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |