아씽 제목에서 처리할려고 그랫더니 글자수 제한에 걸린듯요 ㅠ
void function(int matrix[][],int row,int column);
선언했더니 오류 떠서 matrix[]로 바꿧더니 계획한데로 굴러가지 않기 때문에 뒷부분에 오류가 낫지만 저부분은 돌아가데요...
원래 함수에는 행렬로 구성된 배열 입력 못하나요?
그런거 표현할 방법이 없나요?
원래 실행할려고 햇던거는 행렬 입력받아서
그 행렬만큼 랜덤으로 0이나 1출력후에
빙고체크하는 거 만들려고 햇거든요ㅠㅠ
코드첨부합니다.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void createchecker(int checker[][],int row,int column);
void checkchecker(int checker[][],int row,int cloumn);
int main()
{
int checkers[8][8];
createchecker(checkers,8,8);
checkchecker(checkers,8,8);
return 0;
}
void createchecker(int checker[][],int row,int column)
{
srand(time(0));
for(int i = 0; i < row; i++)
{
for(int j = 0; j < column; j++)
{
checker[i][j] = rand() % 2;
cout << checker[i][j] << " ";
}
cout << "\n";
}
}
void checkchecker(int checker[][],int row,int column)
{
int save;
bool check;
for(int i = 0; i < row; i++)
{
save = checker[i][0];
for(int j = 0; j < column; j++)
{
if(save != checker[i][j])
{
check = false;
break;
}
check = true;
}
if(check == true)
cout << i << "번째 행 " << save << "로 빙고~ " << endl;
}
for(int i = 0; i < column; i++)
{
save = checker[0][i];
for(int j = 0; j < row; j++)
{
if(save != checker[j][i])
{
check = false;
break;
}
check = true;
}
if(check == true)
cout << i << "번째 열 " << save << "로 빙고~ " << endl;
}
if(row == column)
{
save = checker[0][0];
for(int i = 0; i < row; i++)
{
if(save != checker[i][i])
{
check = false;
break;
}
check = true;
}
if(check == true)
cout << "대각선 빙고" << endl;
save = checker[0][row];
for(int i = 0; i < row; i++)
{
if(save != checker[i][row - i])
{
check = false;
break;
}
check = true;
}
if(check == true)
cout << "대각선 빙고" << endl;
}
}
int **
@dd 글쓴이인데요 포인터로 해결되는 문제인가요? 아직 포인터는 책보고 끄적끄적 거리고 잇어서요...
또는 int checker[][8]로 해주면 됨
@dd 감사합니다 그러니깐 2차이상의 행렬에서는 한개만 입력받을수 잇고 나머지는 지정을 해줘야 하는거네요?ㅠㅠ 아니면 포인터를 배우거나? 감사합니다
말씀하신데로 코딩햇더니 금방되네요.. 감사합니다^^