More actions
imported>chj878194 No edit summary |
No edit summary |
||
| (7 intermediate revisions by 2 users not shown) | |||
| Line 56: | Line 56: | ||
void load(int a, int b, int c, int d); | void load(int a, int b, int c, int d); | ||
int reg[4] | int reg[4]; | ||
short mem[4]; | |||
void main() | void main() | ||
{ | { | ||
int a[8], chk=0; | int a[8], chk = 0, chk2 = 0; | ||
int x1, x2, y1, y2; | |||
//1번 | //1번 | ||
| Line 96: | Line 98: | ||
//3번 | //3번 | ||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | ||
while (1) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | |||
for (int i = 0; i < 4; i++) | |||
{ | |||
if (a[i] == 1) | |||
{ | |||
chk++; | |||
} | |||
if (a[i] == 0) | |||
{ | |||
chk2++; | |||
} | |||
} | |||
if (chk == 4) | |||
{ | |||
break; | |||
} | |||
chk = 0; | |||
if (chk2 == 4) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
chk2 = 0; | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n"); | |||
} | |||
void load(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[0] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[0] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[0] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[0] = mem[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[1] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[1] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[1] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[1] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[2] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[2] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[2] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[2] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[3] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[3] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[3] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[3] = mem[3]; | |||
} | |||
} | |||
} | |||
} | |||
== 문제 4 == | |||
#include<stdio.h> | |||
void load(int a, int b, int c, int d); | |||
void add(int a, int b, int c, int d); | |||
void mul(int a, int b, int c, int d); | |||
void save(int a, int b, int c, int d); | |||
int reg[4]; | |||
short mem[4]; | |||
void main() | |||
{ | |||
int a[8], chk = 0, chk2 = 0; | |||
int x1, x2, y1, y2; | |||
//1번 | |||
printf("Team: 최현준 김경찬 변영무\n"); | |||
/* | |||
while (4) | while (4) | ||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]); | |||
for (int i = 0; i < 4; i++) | |||
{ | |||
if (a[i] == 1) | |||
{ | |||
chk++; | |||
} | |||
} | |||
if (chk == 4) | |||
{ | |||
break; | |||
} | |||
chk = 0; | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
printf("%d ", a[i]); | |||
} | |||
printf("\n"); | |||
}*/ | |||
/* | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | { | ||
| Line 106: | Line 276: | ||
{ | { | ||
chk++; | chk++; | ||
} | |||
if (a[i] == 0) | |||
{ | |||
chk2++; | |||
} | } | ||
} | } | ||
| Line 113: | Line 287: | ||
} | } | ||
chk = 0; | chk = 0; | ||
if (chk2 == 4) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
chk2 = 0; | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n");*/ | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | |||
load(a[ | scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | ||
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0) | |||
{ | |||
add(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1) | |||
{ | |||
mul(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1) | |||
{ | |||
break; | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1) | |||
{ | |||
save(x1, x2, y1, y2); | |||
} | |||
} | } | ||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | ||
printf("\n"); | printf("\n"); | ||
} | |||
void load(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[0] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[0] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[0] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[0] = mem[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[1] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[1] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[1] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[1] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[2] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[2] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[2] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[2] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[3] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[3] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[3] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[3] = mem[3]; | |||
} | |||
} | |||
} | |||
} | |||
void add(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] + reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] + reg[3]; | |||
} | |||
} | |||
} | |||
void mul(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] * reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] * reg[3]; | |||
} | |||
} | |||
} | |||
void save(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[0] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[0] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[0] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[0] = reg[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[1] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[1] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[1] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[1] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[2] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[2] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[2] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[2] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[3] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[3] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[3] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[3] = reg[3]; | |||
} | |||
} | |||
} | |||
} | |||
== 문제 5 == | |||
#include<stdio.h> | |||
void load(int a, int b, int c, int d); | |||
void add(int a, int b, int c, int d); | |||
void mul(int a, int b, int c, int d); | |||
void save(int a, int b, int c, int d); | |||
void equal(int a, int b, int c, int d); | |||
int reg[4], equ = 0; | |||
short mem[4]; | |||
void main() | |||
{ | |||
int a[8], chk = 0, chk2 = 0; | |||
int x1, x2, y1, y2; | |||
//1번 | |||
printf("Team: 최현준 김경찬 변영무\n"); | |||
/* | |||
while (4) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]); | |||
for (int i = 0; i < 4; i++) | |||
{ | |||
if (a[i] == 1) | |||
{ | |||
chk++; | |||
} | |||
} | |||
if (chk == 4) | |||
{ | |||
break; | |||
} | |||
chk = 0; | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
printf("%d ", a[i]); | |||
} | |||
printf("\n"); | |||
}*/ | |||
/* | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | |||
for (int i = 0; i < 4; i++) | |||
{ | |||
if (a[i] == 1) | |||
{ | |||
chk++; | |||
} | |||
if (a[i] == 0) | |||
{ | |||
chk2++; | |||
} | |||
} | |||
if (chk == 4) | |||
{ | |||
break; | |||
} | |||
chk = 0; | |||
if (chk2 == 4) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
chk2 = 0; | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n");*/ | |||
/* | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | |||
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0) | |||
{ | |||
add(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1) | |||
{ | |||
mul(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1) | |||
{ | |||
break; | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1) | |||
{ | |||
save(x1, x2, y1, y2); | |||
} | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n");*/ | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | |||
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0) | |||
{ | |||
add(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1) | |||
{ | |||
mul(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1) | |||
{ | |||
break; | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1) | |||
{ | |||
save(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 1 && a[2] == 0 && a[3] == 0) | |||
{ | |||
equal(x1, x2, y1, y2); | |||
} | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n"); | |||
} | } | ||
void load(int | void load(int x1, int x2, int y1, int y2) | ||
{ | { | ||
for (int i = 0; i < 8; i++) | for (int i = 0; i < 8; i++) | ||
| Line 144: | Line 817: | ||
} | } | ||
} | } | ||
if (y1 == 0 && y2 == 1) | |||
{ | { | ||
if (x1 == 0 && x2 == 0) | if (x1 == 0 && x2 == 0) | ||
| Line 203: | Line 876: | ||
} | } | ||
} | } | ||
== | |||
void add(int x1, int x2, int y1, int y2) | |||
== | { | ||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] + reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] + reg[3]; | |||
} | |||
} | |||
} | |||
void mul(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] * reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] * reg[3]; | |||
} | |||
} | |||
} | |||
void save(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[0] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[0] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[0] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[0] = reg[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[1] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[1] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[1] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[1] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[2] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[2] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[2] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[2] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[3] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[3] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[3] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[3] = reg[3]; | |||
} | |||
} | |||
} | |||
} | |||
void equal(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[0] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[0] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[0] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[0] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[1] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[1] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[1] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[1] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[2] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[2] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[2] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[2] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[3] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[3] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[3] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[3] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
} | |||
== 문제 6 == | == 문제 6 == | ||
#include<stdio.h> | |||
void load(int a, int b, int c, int d); | |||
void add(int a, int b, int c, int d); | |||
void mul(int a, int b, int c, int d); | |||
void save(int a, int b, int c, int d); | |||
void equal(int a, int b, int c, int d); | |||
int beq(int a, int b, int c, int d); | |||
int reg[4], equ = 0; | |||
short mem[4]; | |||
void main() | |||
{ | |||
int a[8], chk = 0, chk2 = 0; | |||
int x1, x2, y1, y2; | |||
//1번 | |||
printf("Team: 최현준 김경찬 변영무\n"); | |||
scanf(" %d %d %d %d %d %d %d %d", &reg[0], &reg[1], &reg[2], &reg[3], &mem[0], &mem[1], &mem[2], &mem[3]); | |||
while (1) | |||
{ | |||
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2); | |||
if (chk == 0) | |||
{ | |||
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0) | |||
{ | |||
load(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0) | |||
{ | |||
add(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1) | |||
{ | |||
mul(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1) | |||
{ | |||
save(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 0 && a[1] == 1 && a[2] == 0 && a[3] == 0) | |||
{ | |||
equal(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 1 && a[1] == 0 && a[2] == 0 && a[3] == 0) | |||
{ | |||
chk = beq(x1, x2, y1, y2); | |||
} | |||
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1) | |||
{ | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
chk--; | |||
} | |||
} | |||
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]); | |||
printf("\n"); | |||
} | |||
void load(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[0] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[0] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[0] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[0] = mem[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[1] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[1] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[1] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[1] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[2] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[2] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[2] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[2] = mem[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
reg[3] = mem[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
reg[3] = mem[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
reg[3] = mem[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
reg[3] = mem[3]; | |||
} | |||
} | |||
} | |||
} | |||
void add(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] + reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] + reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] + reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] + reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] + reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] + reg[3]; | |||
} | |||
} | |||
} | |||
void mul(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[0] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[0] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[0] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[0] * reg[3]; | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[1] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[1] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[1] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[1] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[2] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[2] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[2] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[2] * reg[3]; | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
reg[0] = reg[3] * reg[0]; | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
reg[1] = reg[3] * reg[1]; | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
reg[2] = reg[3] * reg[2]; | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
reg[3] = reg[3] * reg[3]; | |||
} | |||
} | |||
} | |||
void save(int x1, int x2, int y1, int y2) | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[0] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[0] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[0] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[0] = reg[3]; | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[1] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[1] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[1] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[1] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[2] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[2] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[2] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[2] = reg[3]; | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
mem[3] = reg[0]; | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
mem[3] = reg[1]; | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
mem[3] = reg[2]; | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
mem[3] = reg[3]; | |||
} | |||
} | |||
} | |||
} | |||
void equal(int x1, int x2, int y1, int y2) | |||
{ | |||
if (x1 == 0 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[0] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[0] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[0] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[0] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 0 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[1] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[1] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[1] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[1] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 1 && x2 == 0) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[2] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[2] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[2] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[2] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
if (x1 == 1 && x2 == 1) | |||
{ | |||
if (y1 == 0 && y2 == 0) | |||
{ | |||
if (reg[3] != reg[0]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 0 && y2 == 1) | |||
{ | |||
if (reg[3] != reg[1]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 0) | |||
{ | |||
if (reg[3] != reg[2]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
if (y1 == 1 && y2 == 1) | |||
{ | |||
if (reg[3] != reg[3]) | |||
{ | |||
equ = 0; | |||
printf("%d\n", equ); | |||
} | |||
else | |||
{ | |||
equ = 1; | |||
printf("%d\n", equ); | |||
} | |||
} | |||
} | |||
} | |||
int beq(int x1, int x2, int y1, int y2) | |||
{ | |||
int sum = 0; | |||
if (equ == 1) | |||
{ | |||
sum = sum + y2 + (y1 * 2) + (x2 * 4) + (x1 * 8); | |||
} | |||
return sum; | |||
} | |||
----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ||
[[CodeRace]] [[CodeRace/2016]] | [[CodeRace]] [[CodeRace/2016]] | ||
Latest revision as of 12:16, 20 May 2016
CodeRace 2016 답안 제출 포멧입니다.
강사: 최현준 새싹: 변영무, 김경찬
문제 1
#include<stdio.h>
void main()
{
printf("@@@@@@@@@@@@@@@@@@@@@@@@\n@ 초코하임반 @\n@ 멘토: 최현준 @\n@ 멘티: 김경찬, 변영무 @\n@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n");
printf("Team: 최현준 김경찬 변영무\n");
}
문제 2
#include<stdio.h>
void main()
{
int a[8], chk=0;
printf("@@@@@@@@@@@@@@@@@@@@@@@@\n@ 초코하임반 @\n@ 멘토: 최현준 @\n@ 멘티: 김경찬, 변영무 @\n@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n");
printf("Team: 최현준 김경찬 변영무\n");
while (4)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
for (int i = 0; i < 8; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}
}
문제 3
#include<stdio.h>
void load(int a, int b, int c, int d);
int reg[4];
short mem[4];
void main()
{
int a[8], chk = 0, chk2 = 0;
int x1, x2, y1, y2;
//1번
printf("Team: 최현준 김경찬 변영무\n");
/*
while (4)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
for (int i = 0; i < 8; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}*/
//3번
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
if (a[i] == 0)
{
chk2++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
if (chk2 == 4)
{
load(x1, x2, y1, y2);
}
chk2 = 0;
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");
}
void load(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[0] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[0] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[0] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[0] = mem[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[1] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[1] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[1] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[1] = mem[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[2] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[2] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[2] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[2] = mem[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[3] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[3] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[3] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[3] = mem[3];
}
}
}
}
문제 4
#include<stdio.h>
void load(int a, int b, int c, int d);
void add(int a, int b, int c, int d);
void mul(int a, int b, int c, int d);
void save(int a, int b, int c, int d);
int reg[4];
short mem[4];
void main()
{
int a[8], chk = 0, chk2 = 0;
int x1, x2, y1, y2;
//1번
printf("Team: 최현준 김경찬 변영무\n");
/*
while (4)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
for (int i = 0; i < 8; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}*/
/*
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
if (a[i] == 0)
{
chk2++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
if (chk2 == 4)
{
load(x1, x2, y1, y2);
}
chk2 = 0;
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");*/
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
load(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0)
{
add(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1)
{
mul(x1, x2, y1, y2);
}
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1)
{
break;
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1)
{
save(x1, x2, y1, y2);
}
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");
}
void load(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[0] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[0] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[0] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[0] = mem[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[1] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[1] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[1] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[1] = mem[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[2] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[2] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[2] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[2] = mem[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[3] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[3] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[3] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[3] = mem[3];
}
}
}
}
void add(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] + reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] + reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] + reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] + reg[3];
}
}
}
void mul(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] * reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] * reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] * reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] * reg[3];
}
}
}
void save(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[0] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[0] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[0] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[0] = reg[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[1] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[1] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[1] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[1] = reg[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[2] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[2] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[2] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[2] = reg[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[3] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[3] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[3] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[3] = reg[3];
}
}
}
}
문제 5
#include<stdio.h>
void load(int a, int b, int c, int d);
void add(int a, int b, int c, int d);
void mul(int a, int b, int c, int d);
void save(int a, int b, int c, int d);
void equal(int a, int b, int c, int d);
int reg[4], equ = 0;
short mem[4];
void main()
{
int a[8], chk = 0, chk2 = 0;
int x1, x2, y1, y2;
//1번
printf("Team: 최현준 김경찬 변영무\n");
/*
while (4)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
for (int i = 0; i < 8; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}*/
/*
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
for (int i = 0; i < 4; i++)
{
if (a[i] == 1)
{
chk++;
}
if (a[i] == 0)
{
chk2++;
}
}
if (chk == 4)
{
break;
}
chk = 0;
if (chk2 == 4)
{
load(x1, x2, y1, y2);
}
chk2 = 0;
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");*/
/*
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
load(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0)
{
add(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1)
{
mul(x1, x2, y1, y2);
}
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1)
{
break;
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1)
{
save(x1, x2, y1, y2);
}
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");*/
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
load(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0)
{
add(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1)
{
mul(x1, x2, y1, y2);
}
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1)
{
break;
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1)
{
save(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 1 && a[2] == 0 && a[3] == 0)
{
equal(x1, x2, y1, y2);
}
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");
}
void load(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[0] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[0] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[0] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[0] = mem[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[1] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[1] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[1] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[1] = mem[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[2] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[2] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[2] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[2] = mem[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[3] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[3] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[3] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[3] = mem[3];
}
}
}
}
void add(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] + reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] + reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] + reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] + reg[3];
}
}
}
void mul(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] * reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] * reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] * reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] * reg[3];
}
}
}
void save(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[0] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[0] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[0] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[0] = reg[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[1] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[1] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[1] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[1] = reg[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[2] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[2] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[2] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[2] = reg[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[3] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[3] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[3] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[3] = reg[3];
}
}
}
}
void equal(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
if (reg[0] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[0] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[0] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[0] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
if (reg[1] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[1] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[1] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[1] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
if (reg[2] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[2] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[2] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[2] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
if (reg[3] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[3] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[3] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[3] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
}
문제 6
#include<stdio.h>
void load(int a, int b, int c, int d);
void add(int a, int b, int c, int d);
void mul(int a, int b, int c, int d);
void save(int a, int b, int c, int d);
void equal(int a, int b, int c, int d);
int beq(int a, int b, int c, int d);
int reg[4], equ = 0;
short mem[4];
void main()
{
int a[8], chk = 0, chk2 = 0;
int x1, x2, y1, y2;
//1번
printf("Team: 최현준 김경찬 변영무\n");
scanf(" %d %d %d %d %d %d %d %d", ®[0], ®[1], ®[2], ®[3], &mem[0], &mem[1], &mem[2], &mem[3]);
while (1)
{
scanf(" %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &x1, &x2, &y1, &y2);
if (chk == 0)
{
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
load(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 0)
{
add(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 1 && a[3] == 1)
{
mul(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 1)
{
save(x1, x2, y1, y2);
}
else if (a[0] == 0 && a[1] == 1 && a[2] == 0 && a[3] == 0)
{
equal(x1, x2, y1, y2);
}
else if (a[0] == 1 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
chk = beq(x1, x2, y1, y2);
}
else if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1)
{
break;
}
}
else
{
chk--;
}
}
printf("%d %d %d %d %d %d %d %d\n", reg[0], reg[1], reg[2], reg[3], mem[0], mem[1], mem[2], mem[3]);
printf("\n");
}
void load(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[0] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[0] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[0] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[0] = mem[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[1] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[1] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[1] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[1] = mem[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
reg[2] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[2] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[2] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[2] = mem[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
reg[3] = mem[0];
}
if (x1 == 0 && x2 == 1)
{
reg[3] = mem[1];
}
if (x1 == 1 && x2 == 0)
{
reg[3] = mem[2];
}
if (x1 == 1 && x2 == 1)
{
reg[3] = mem[3];
}
}
}
}
void add(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] + reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] + reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] + reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] + reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] + reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] + reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] + reg[3];
}
}
}
void mul(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[0] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[0] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[0] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[0] * reg[3];
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[1] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[1] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[1] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[1] * reg[3];
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[2] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[2] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[2] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[2] * reg[3];
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
reg[0] = reg[3] * reg[0];
}
if (y1 == 0 && y2 == 1)
{
reg[1] = reg[3] * reg[1];
}
if (y1 == 1 && y2 == 0)
{
reg[2] = reg[3] * reg[2];
}
if (y1 == 1 && y2 == 1)
{
reg[3] = reg[3] * reg[3];
}
}
}
void save(int x1, int x2, int y1, int y2)
{
for (int i = 0; i < 8; i++)
{
if (y1 == 0 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[0] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[0] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[0] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[0] = reg[3];
}
}
if (y1 == 0 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[1] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[1] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[1] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[1] = reg[3];
}
}
if (y1 == 1 && y2 == 0)
{
if (x1 == 0 && x2 == 0)
{
mem[2] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[2] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[2] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[2] = reg[3];
}
}
if (y1 == 1 && y2 == 1)
{
if (x1 == 0 && x2 == 0)
{
mem[3] = reg[0];
}
if (x1 == 0 && x2 == 1)
{
mem[3] = reg[1];
}
if (x1 == 1 && x2 == 0)
{
mem[3] = reg[2];
}
if (x1 == 1 && x2 == 1)
{
mem[3] = reg[3];
}
}
}
}
void equal(int x1, int x2, int y1, int y2)
{
if (x1 == 0 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
if (reg[0] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[0] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[0] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[0] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 0 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
if (reg[1] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[1] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[1] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[1] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 1 && x2 == 0)
{
if (y1 == 0 && y2 == 0)
{
if (reg[2] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[2] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[2] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[2] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
if (x1 == 1 && x2 == 1)
{
if (y1 == 0 && y2 == 0)
{
if (reg[3] != reg[0])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 0 && y2 == 1)
{
if (reg[3] != reg[1])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 0)
{
if (reg[3] != reg[2])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
if (y1 == 1 && y2 == 1)
{
if (reg[3] != reg[3])
{
equ = 0;
printf("%d\n", equ);
}
else
{
equ = 1;
printf("%d\n", equ);
}
}
}
}
int beq(int x1, int x2, int y1, int y2)
{
int sum = 0;
if (equ == 1)
{
sum = sum + y2 + (y1 * 2) + (x2 * 4) + (x1 * 8);
}
return sum;
}