Skip to content

Instantly share code, notes, and snippets.

@doojinkang
Created August 20, 2017 16:07
Show Gist options
  • Save doojinkang/c2db89aa4a547c940538afb42b3ce483 to your computer and use it in GitHub Desktop.
Save doojinkang/c2db89aa4a547c940538afb42b3ce483 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int buffer[100];
int test_buffer(int upper) {
for ( int i = 1; i <= upper; i++) {
for ( int j = i+1; j <= upper; j++) {
if ( buffer[i] == buffer[j])
return 0;
}
}
return 1;
}
int main() {
int nth = 0;
int num = 0;
fscanf(stdin, "참가자의 수를 정하시오 : %d번째 : %d\n", &nth, &num);
buffer[nth] = num;
while ( ! feof(stdin)) {
fscanf(stdin, "%d번째 : %d\n", &nth, &num);
buffer[nth] = num;
}
if ( test_buffer(nth)) {
// printf(" Test Pass\n");
exit(0);
}
else {
printf(" Test Fail :");
for (int i = 1; i <= nth; i++)
printf(" %d", buffer[i]);
printf("\n");
exit(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment