-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3index_copy.cpp
More file actions
70 lines (59 loc) · 1.53 KB
/
Copy path3index_copy.cpp
File metadata and controls
70 lines (59 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable:4996)
int chk[100];
int ret;
int normal_idx, error_idx;
int check(int tmp){
//0-99사이의 임의의 난수값을 하나 받아온다.
//해당 값이 이미 불량/정상 확인 된 동전인지 확인하고
//확인되지 않은 동전일경우 tmp값을
//확인된 동전일경우 check(tmp_new)시행
if(chk[tmp] == -1) {
chk[tmp] = 2;
return tmp;
}
else {
int tmp_new;
tmp_new = rand() % 100;
check(tmp_new);
}
}
int main(){
int a[100];
int b[100];
memset(chk, -1, sizeof(chk));//불량/정상 체크배열 초기화
memset(a, -1, sizeof(a));
memset(b, -1, sizeof(b)); //기존 배열 초기화
chk[0] = 1;
chk[7] = 0;
int k = 0;
for(int i = 1; i < 33; i++ ){ // 2개의 인덱스가 남을때까지 반복
int tmp;
tmp = rand() % 100;
b[0] = check(tmp);
tmp = rand() % 100;
b[1] = check(tmp);
tmp = rand() % 100;
b[2] = check(tmp);
printf("b[0] %d, b[1] %d, b[2] %d\n", b[0], b[1], b[2] );
}
for(int i = 0; i < 100; i++){
if(chk[i] == -1) {
b[0] = i;
chk[i] = 2;
break;
}
}
for(int i = 0; i < 100; i++){
if(chk[i] == -1) {
b[1] = i;
chk[i] = 2;
break;
}
}
//모든 동전의 불량/정상 여부 검사를 마침
printf("b[0] %d, b[1] %d\n", b[0], b[1] );
scanf("%d\n", &k);
}