c++ 배열 최대값정리하기~

joohyuncha의 이미지

#include
#include

using namespace std;

const int SIZE = 12;
const int ROWMAX = 4;
const int COLMAX = 3;

void makeTwoDimension(int array[], int ROWMAX, int twoDimensionArray[][COLMAX]);

void printTwoDimensionArray(int twoDimensionArray[][COLMAX], int ROWMAX);

void findColMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxColArray[]);

void findRowMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxRowArray[]);

void printTwoDimensionArrayWithMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxRowArray[], int maxColArray[]);

int main()
{
int array[SIZE] = {89, 88, 96, 23, 77, 12, 36, 28, 93, 83, 25, 30};
int twoDimensionArray[ROWMAX][COLMAX];
int a=0, b=0;
int maxColArray[ROWMAX];
int maxROWArray[COLMAX];

cout<<"1array"< for(int i=0; i cout< cout<

makeTwoDimension( array, ROWMAX, twoDimensionArray);
cout< cout<<"2array"<

printTwoDimensionArray( twoDimensionArray, ROWMAX);
cout<

findColMax(twoDimensionArray, ROWMAX, maxColArray);

printTwoDimensionArrayWithMax(twoDimensionArray, ROWMAX , maxROWArray, maxColArray);

return 0;
}
void makeTwoDimension(int array[], int ROWMAX, int twoDimensionArray[][COLMAX])
{
for(int b=0; b for(int a=0; a twoDimensionArray[b][a] = array[b*COLMAX +a];
}

void printTwoDimensionArray(int twoDimensionArray[][COLMAX], int ROWMAX)
{
for(int b = 0; b

for(int a = 0; a < COLMAX; a++)

cout << twoDimensionArray[b][a] << " ";

cout << endl;

}

void findColMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxColArray[])
{
int c=0;
for(int b=0; b for(int a = 0; a < COLMAX; a++)
if(twoDimensionArray[b][a]>c)
c=twoDimensionArray[b][a];
for(int i=0; i maxColArray[i]=c;
}
}

void findRowMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxRowArray[])
{
int c=0;
for(int b=0; b
for(int a = 0; a < ROWMAX; a++){
if(twoDimensionArray[b][a]>c)
c=twoDimensionArray[b][a];
maxRowArray[COLMAX+1]=c;
}
}
}

void printTwoDimensionArrayWithMax(int twoDimensionArray[][COLMAX], int ROWMAX, int maxRowArray[], int maxColArray[])
{
int a,b,c =0;
int p[5][4];
for(b = 0; b for(a = 0; a < COLMAX; a++)
twoDimensionArray[b+1][a] = maxColArray[ROWMAX];
twoDimensionArray[b][a+1] = maxRowArray[COLMAX];
twoDimensionArray[b][a];
}
p[ROWMAX+1][COLMAX+1]=twoDimensionArray[b+1][a+1];
cout << p[ROWMAX+1][COLMAX+1] << " ";

cout << endl;

}

일단은 제가 짜본거입니다..

결과값을 저렇게 출력해야됩니다.. 고수님들 급해요 도와주세요~~

one dineension array

89 88 96 23 77 12 36 28 9

3 83 25 30

two dineension array

89 88 96

23 77 12

36 28 93

83 25 30

two dineension array with max

max

89 88 96 96

23 77 12 77

36 28 93 93

83 25 30 83

max 89 88 96

익명 사용자의 이미지

함수명과 변수명을 너무나도 친절하게 만드시는 바람에 너무 길어서 오히려 가독성이 안좋아서 코드 보기가 힘들어요

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.