U E D R , A S I H C RSS

Code Race/2016/코드레이스쟁반

CodeRace 2016 답안 제출 포멧입니다.

강사: 이승현
새싹: 유성현

문제 1

#define _CRT_SECURE_NOWARNINGS
#include <stdio.h>



int main(void)
{
	printf("Team : 이승현, 유성현");


	
	return 0;
}

문제 2

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>



int main(void)
{
	int i = 0;
	char arr[16][999];


	while (1)
	{


		
		gets(arr[i]);

		if (arr[i][0] == '1' && arr[i][2] == '1' && arr[i][4] == '1' && arr[i][6] == '1')
			break;
		
		i++;
	
		

	}


	printf("\nTeam : 이승현, 유성현\n");

	for (int j = 0; j != i; j++)
	{
		printf("%s", arr[j]);
		printf("\n");
	}
	
	return 0;
}

문제 3

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int reg00, reg01, reg11, reg10;
int mem00, mem01, mem11, mem10;

int load(int a, int b, int c, int d);


int main(void)
{
	int i = 0;
	char arr[16][999];

	scanf("%d", &reg00);
	scanf("%d", &reg01);
	scanf("%d", &reg10);
	scanf("%d", &reg11);

	scanf("%d", &mem00);
	scanf("%d", &mem01);
	scanf("%d", &mem10);
	scanf("%d", &mem11);


	
	while (1)
	{


		
		gets(arr[i]);


		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '0')
			load(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '1' && arr[i][2] == '1' && arr[i][4] == '1' && arr[i][6] == '1')
			break;
		
		i++;
	
		

	}


	printf("\nTeam : 이승현, 유성현\n");

	/*
	for (int j = 0; j != i; j++)
	{
		printf("%s", arr[j]);
		printf("\n");
	}
	*/

	printf("%d %d %d %d %d %d %d %d\n", reg00, reg01, reg10, reg11, mem00, mem01, mem10, mem11);
	
	return 0;
}

int load(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // mem 00
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem00;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem00;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem00;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem00;
	}

	if (a == 0 && b == 1) // mem 01
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem01;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem01;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem01;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem10;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem10;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem10;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem11;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem11;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem11;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem11;
	}

	return 0;
	

}

문제 4


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int reg00, reg01, reg11, reg10;
int mem00, mem01, mem11, mem10;

int load(int a, int b, int c, int d);
int save(int a, int b, int c, int d);
int add(int a, int b, int c, int d);
int mul(int a, int b, int c, int d);


int main(void)
{
	int i = 0;
	char arr[16][999];

	scanf("%d", &reg00);
	scanf("%d", &reg01);
	scanf("%d", &reg10);
	scanf("%d", &reg11);

	scanf("%d", &mem00);
	scanf("%d", &mem01);
	scanf("%d", &mem10);
	scanf("%d", &mem11);


	
	while (1)
	{


		
		gets(arr[i]);


		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '0')
			load(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '1' && arr[i][2] == '1' && arr[i][4] == '1' && arr[i][6] == '1')
			break;

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '0')
			add(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '1')
			mul(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '1')
			save(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');
		
		i++;
	
		

	}


	printf("\nTeam : 이승현, 유성현\n");

	/*
	for (int j = 0; j != i; j++)
	{
		printf("%s", arr[j]);
		printf("\n");
	}
	*/

	printf("%d %d %d %d %d %d %d %d\n", reg00, reg01, reg10, reg11, mem00, mem01, mem10, mem11);
	
	return 0;
}

int load(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // mem 00
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem00;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem00;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem00;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem00;
	}

	if (a == 0 && b == 1) // mem 01
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem01;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem01;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem01;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem10;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem10;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem10;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem11;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem11;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem11;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem11;
	}

	return 0;
	

}

int add(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 + reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 + reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 + reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 + reg11;
	}

	return 0;

}

int mul(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 * reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 * reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 * reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 * reg11;
	}

	return 0;

}

int save(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // reg 00
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg00;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg00;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg00;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg00;
	}

	if (a == 0 && b == 1) 
	{
		if (c == 0 && d == 0) 
			mem00 = reg01;
		if (c == 0 && d == 1) 
			mem01 = reg01;
		if (c == 1 && d == 0) 
			mem10 = reg01;
		if (c == 1 && d == 1) 
			mem11 = reg01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg10;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg10;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg10;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg11;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg11;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg11;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg11;
	}

	return 0;


}

문제 5


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int reg00, reg01, reg11, reg10;
int mem00, mem01, mem11, mem10;
int equ;

int load(int a, int b, int c, int d);
int save(int a, int b, int c, int d);
int add(int a, int b, int c, int d);
int mul(int a, int b, int c, int d);
int equal(int a, int b, int c, int d);



int main(void)
{
	int i = 0;
	char arr[16][999];
	int value[9999];
	int k = 0;

	scanf("%d", &reg00);
	scanf("%d", &reg01);
	scanf("%d", &reg10);
	scanf("%d", &reg11);

	scanf("%d", &mem00);
	scanf("%d", &mem01);
	scanf("%d", &mem10);
	scanf("%d", &mem11);


	
	while (1)
	{


		
		gets(arr[i]);


		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '0')
			load(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '1' && arr[i][2] == '1' && arr[i][4] == '1' && arr[i][6] == '1')
			break;

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '0')
			add(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '1')
			mul(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '1')
			save(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '1' && arr[i][4] == '0' && arr[i][6] == '0')
		{

			equal(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');
			value[k] = equ;
			k++;
		}
		i++;
	
		

	}


	printf("\nTeam : 이승현, 유성현\n");

	/*
	for (int j = 0; j != i; j++)
	{
		printf("%s", arr[j]);
		printf("\n");
	}
	*/

	for (int m = 0; m != k; m++)
		printf("%d\n", value[m]);


	printf("%d %d %d %d %d %d %d %d\n", reg00, reg01, reg10, reg11, mem00, mem01, mem10, mem11);
	
	

	return 0;
}

int load(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // mem 00
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem00;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem00;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem00;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem00;
	}

	if (a == 0 && b == 1) // mem 01
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem01;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem01;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem01;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem10;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem10;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem10;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem11;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem11;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem11;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem11;
	}

	return 0;
	

}

int add(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 + reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 + reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 + reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 + reg11;
	}

	return 0;

}

int mul(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 * reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 * reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 * reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 * reg11;
	}

	return 0;

}

int save(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // reg 00
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg00;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg00;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg00;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg00;
	}

	if (a == 0 && b == 1) 
	{
		if (c == 0 && d == 0) 
			mem00 = reg01;
		if (c == 0 && d == 1) 
			mem01 = reg01;
		if (c == 1 && d == 0) 
			mem10 = reg01;
		if (c == 1 && d == 1) 
			mem11 = reg01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg10;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg10;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg10;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg11;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg11;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg11;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg11;
	}

	return 0;


}

int equal(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg00 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg00 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg00 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg00 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg01 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg01 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg01 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg01 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg10 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg10 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg10 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg10 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg11 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg11 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg11 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg11 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	return 0;

}

문제 6


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int reg00, reg01, reg11, reg10;
int mem00, mem01, mem11, mem10;
int equ;

int load(int a, int b, int c, int d);
int save(int a, int b, int c, int d);
int add(int a, int b, int c, int d);
int mul(int a, int b, int c, int d);
int equal(int a, int b, int c, int d);
int beq(int a, int b, int c, int d);



int main(void)
{
	int i = 0;
	char arr[16][999];
	int value[9999];
	int k = 0;
	int b = 0;

	scanf("%d", &reg00);
	scanf("%d", &reg01);
	scanf("%d", &reg10);
	scanf("%d", &reg11);

	scanf("%d", &mem00);
	scanf("%d", &mem01);
	scanf("%d", &mem10);
	scanf("%d", &mem11);


	
	while (1)
	{


		
		gets(arr[i]);

		if (b != 0)
		{
			b--;
			continue;
		}

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '0')
			load(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '1' && arr[i][2] == '1' && arr[i][4] == '1' && arr[i][6] == '1')
			break;

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '0')
			add(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '1' && arr[i][6] == '1')
			mul(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '1')
			save(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');

		if (arr[i][0] == '0' && arr[i][2] == '1' && arr[i][4] == '0' && arr[i][6] == '0')
		{

			equal(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');
			value[k] = equ;
			k++;
		}

		if (arr[i][0] == '1' && arr[i][2] == '0' && arr[i][4] == '0' && arr[i][6] == '0')
		{
			if (equ == 1)
			{
				b = beq(arr[i][8] - '0', arr[i][10] - '0', arr[i][12] - '0', arr[i][14] - '0');
			}

		}

		i++;
	
		

	}


	printf("\nTeam : 이승현, 유성현\n");

	/*
	for (int j = 0; j != i; j++)
	{
		printf("%s", arr[j]);
		printf("\n");
	}
	*/

	for (int m = 0; m != k; m++)
		printf("%d\n", value[m]);


	printf("%d %d %d %d %d %d %d %d\n", reg00, reg01, reg10, reg11, mem00, mem01, mem10, mem11);
	
	

	return 0;
}

int load(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // mem 00
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem00;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem00;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem00;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem00;
	}

	if (a == 0 && b == 1) // mem 01
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem01;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem01;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem01;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem10;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem10;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem10;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = mem11;
		if (c == 0 && d == 1) //reg 01
			reg01 = mem11;
		if (c == 1 && d == 0) //reg 10
			reg10 = mem11;
		if (c == 1 && d == 1) //reg 11
			reg11 = mem11;
	}

	return 0;
	

}

int add(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 + reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 + reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 + reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 + reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 + reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 + reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 + reg11;
	}

	return 0;

}

int mul(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg00 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg00 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg00 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg00 * reg11;
	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg01 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg01 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg01 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg01 * reg11;
	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg10 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg10 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg10 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg10 * reg11;
	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
			reg00 = reg11 * reg00;
		if (c == 0 && d == 1) //reg 01
			reg01 = reg11 * reg01;
		if (c == 1 && d == 0) //reg 10
			reg10 = reg11 * reg10;
		if (c == 1 && d == 1) //reg 11
			reg11 = reg11 * reg11;
	}

	return 0;

}

int save(int a, int b, int c, int d)
{

	if (a == 0 && b == 0) // reg 00
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg00;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg00;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg00;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg00;
	}

	if (a == 0 && b == 1) 
	{
		if (c == 0 && d == 0) 
			mem00 = reg01;
		if (c == 0 && d == 1) 
			mem01 = reg01;
		if (c == 1 && d == 0) 
			mem10 = reg01;
		if (c == 1 && d == 1) 
			mem11 = reg01;
	}

	if (a == 1 && b == 0) // mem 10
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg10;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg10;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg10;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg10;
	}

	if (a == 1 && b == 1) // mem 11
	{
		if (c == 0 && d == 0) //mem 00
			mem00 = reg11;
		if (c == 0 && d == 1) //mem 01
			mem01 = reg11;
		if (c == 1 && d == 0) //mem 10
			mem10 = reg11;
		if (c == 1 && d == 1) //mem 11
			mem11 = reg11;
	}

	return 0;


}

int equal(int a, int b, int c, int d)
{
	if (a == 0 && b == 0) // reg 00 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg00 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg00 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg00 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg00 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 0 && b == 1) // reg 01 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg01 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg01 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg01 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg01 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 1 && b == 0) // reg 10 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg10 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg10 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg10 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg10 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	if (a == 1 && b == 1) // reg 11 first
	{
		if (c == 0 && d == 0) //reg 00
		{
			if (reg11 == reg00)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 0 && d == 1) //reg 01
		{
			if (reg11 == reg01)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 0) //reg 10
		{
			if (reg11 == reg10)
				equ = 1;
			else
				equ = 0;
		}

		if (c == 1 && d == 1) //reg 11
		{
			if (reg11 == reg11)
				equ = 1;
			else
				equ = 0;
		}

	}

	return 0;

}

int beq(int a, int b, int c, int d)
{
	int dex;
	dex = d * 1 + c * 2 + b * 4 + a * 8;

	return dex;

}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:56
Processing time 0.0290 sec