숙제_남기연
페이지 정보
작성자 심화반남기연 작성일17-06-23 23:43 조회538회 댓글0건첨부파일
-
소스.cpp (483byte) 2회 다운로드 DATE : 2017-06-23 23:43:29
본문
#include <iostream>
using namespace std;
int a[5];
void BubbleSort(int * a)
{
for (int i = 6; i > 0; i--)
for (int j = 0; j <= i - 1; j++)
if (a[j] > a[j + 1])
{
int k = a[i];
a[i] = a[j];
a[j] = k;
}
return;
}
int main()
{
int a[5];
for (int i = 0; i < 5; i++)
cin >> a[i];
int n = 0;
for (int i = 0; i < 5; i++)
n += a[i];
n /= 5;
BubbleSort;
cout << endl << n << endl << a[2] << endl;
return 0;
}
using namespace std;
int a[5];
void BubbleSort(int * a)
{
for (int i = 6; i > 0; i--)
for (int j = 0; j <= i - 1; j++)
if (a[j] > a[j + 1])
{
int k = a[i];
a[i] = a[j];
a[j] = k;
}
return;
}
int main()
{
int a[5];
for (int i = 0; i < 5; i++)
cin >> a[i];
int n = 0;
for (int i = 0; i < 5; i++)
n += a[i];
n /= 5;
BubbleSort;
cout << endl << n << endl << a[2] << endl;
return 0;
}
댓글목록
등록된 댓글이 없습니다.