안녕하세요
알고스팟을 처음 접하게 된 학생입니다.
picnic 문제를 비쥬얼 스튜디오에서 풀고
채점을 받고 싶어서 올렸는데
계속해서 컴파일 오류가 뜨네요
c언어로 작성했는데 왜 채점 프로그램에서만 계속 컴파일이 안되는지 모르겠네요 ㅠㅠ
submission.c: In function ‘main’:
submission.c:37:29: error: passing argument 1 of ‘countPairings’ from incompatible pointer type
outPut[i] = countPairings(taken);
^
submission.c:6:5: note: expected ‘_Bool *’ but argument is of type ‘int *’
int countPairings(bool taken[]);
^
submission.c:17:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &C);
^
submission.c:19:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &C);
^
submission.c:22:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &staticSize, &twinNum);
^
submission.c:29:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &temp1, &temp2);
^
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
int n = 0;
bool areFriends[10][10];
int countPairings(bool taken[]);
int main(void) {
int *taken;
int staticSize = 0;
taken = (int*)malloc(sizeof(int)*staticSize);
int twinNum = 0;
int *outPut;
int C = 0;
outPut = (int*)malloc(sizeof(int)*C);
scanf("%d", &C);
if (C > 50) {
scanf("%d", &C);
}
for (int i = 0; i < C; i++) {
scanf("%d %d", &staticSize, &twinNum);
n = staticSize;
for (int i = 0; i < staticSize; i++) {
taken[i] = false;
}
int temp, temp1, temp2;
for (int i = 0; i < twinNum; i++) {
scanf("%d %d", &temp1, &temp2);
if (temp1 > temp2) {
temp = temp1;
temp1 = temp2;
temp2 = temp;
}
areFriends[temp1][temp2] = true;
}
outPut[i] = countPairings(taken);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if(areFriends[i][j]){
areFriends[i][j] = false;
}
}
}
}
for (int i = 0; i < C; i++) {
printf("%d\n", outPut[i]);
}
return 0;
}
int countPairings(bool taken[]) {
int firstFree = -1;
for (int i = 0; i < n; i++) {
if (!taken[i]) {
firstFree = i;
break;
}
}
if (firstFree == -1) return 1;
int ret = 0;
for (int pairWith = firstFree+1; pairWith < n; pairWith++) {
if (!taken[pairWith] && areFriends[firstFree][pairWith]) {
taken[firstFree] = taken[pairWith] = true;
ret += countPairings(taken);
taken[firstFree] = taken[pairWith] = false;
}
}
return ret;
}
chelgi03
안녕하세요
알고스팟을 처음 접하게 된 학생입니다.
picnic 문제를 비쥬얼 스튜디오에서 풀고
채점을 받고 싶어서 올렸는데
계속해서 컴파일 오류가 뜨네요
c언어로 작성했는데 왜 채점 프로그램에서만 계속 컴파일이 안되는지 모르겠네요 ㅠㅠ
submission.c: In function ‘main’:
submission.c:37:29: error: passing argument 1 of ‘countPairings’ from incompatible pointer type
outPut[i] = countPairings(taken);
^
submission.c:6:5: note: expected ‘_Bool *’ but argument is of type ‘int *’
int countPairings(bool taken[]);
^
submission.c:17:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &C);
^
submission.c:19:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &C);
^
submission.c:22:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &staticSize, &twinNum);
^
submission.c:29:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &temp1, &temp2);
^
9년 전