#include <stdio.h>
#include <stdlib.h>
int num[3][4];
int sum_h[3],sum_y[4];
int main(int argc, char *argv[])
{
int max=0;
int temp=0;
int input[10]={0,};
int i,j;
for(i=0; i<10; i++)
scanf("%d", &input[i]);
fflush(stdin);
//선택정렬
for(i=0; i<9; i++)
{ //1 3 2 4 5 6 7 8 9 50
max = i;
for(j=i+1; j<10; j++)
{
if(input[max]<input[j])
{
max = j; //최대값이 있는 인덱스 저장
}
}
temp = input[i];
input[i] = input[max];
input[max] = temp;
}
for(i=0; i<10; i++)
printf("%d ", input[i]);
system("PAUSE");
return 0;
}
#include <stdlib.h>
int num[3][4];
int sum_h[3],sum_y[4];
int main(int argc, char *argv[])
{
int max=0;
int temp=0;
int input[10]={0,};
int i,j;
for(i=0; i<10; i++)
scanf("%d", &input[i]);
fflush(stdin);
//선택정렬
for(i=0; i<9; i++)
{ //1 3 2 4 5 6 7 8 9 50
max = i;
for(j=i+1; j<10; j++)
{
if(input[max]<input[j])
{
max = j; //최대값이 있는 인덱스 저장
}
}
temp = input[i];
input[i] = input[max];
input[max] = temp;
}
for(i=0; i<10; i++)
printf("%d ", input[i]);
system("PAUSE");
return 0;
}
'Languages > C Language' 카테고리의 다른 글
함수 포인터, void형 포인터, 포인터 배열과 배열을 가리키는 포인터 (0) | 2011.12.28 |
---|---|
Static(정적) 변수 (0) | 2011.12.23 |
C Api, gotoxy(), blue() 함수 등등, 소스 및 사용법 (0) | 2011.12.22 |
재귀함수를 이용한 10진수 -> 2진수,16진수 변환 (0) | 2011.12.22 |