강사: 최다인
새싹: 김상렬

문제 1

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>



int main(void){
	

	printf("Mackerel:최다인, 김상렬");

	return 0;
}

문제 2


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>



int main(void){

	int list[8];
	int i;
	int flag ;


	printf("Mackerel: 최다인, 김상렬 \n");

	while (1){

		flag = 1;
		for (i = 0; i < 8; i++){
			scanf("%d", &list[i]);

		}
		for (i = 0; i < 4; i++){
			if (list[i] == 0){
				flag = 0;
				break;
			}
		}
		if (flag == 1){
			break;
		}
		for (i = 0; i < 8; i++){
			printf("%d ", list[i]);
		}
		printf("\n");
		
	}




return 0;
}

문제 3


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int reg[4];
int mem[4];
//int reg1, reg2, reg3, reg4;
//int mem1, mem2, mem3, mem4;

void load(int, int, int, int);

int main(void){

	int list[8];
	int i;
	int flag ;
	int loadflag;
	

	printf("Mackerel: 최다인, 김상렬 \n");
	for (i = 0; i < 4; i++){
		scanf("%d", &reg[i]);

	}
	for (i = 0; i < 4; i++){
		scanf("%d", &mem[i]);
			
	}


	
	while (1){

		flag = 1;
		loadflag = 1;


		for (i = 0; i < 8; i++){
			scanf("%d", &list[i]);

		}
		for (i = 0; i < 4; i++){
			if (list[i] == 0){
				flag = 0;
				break;
			}
		}
		if (flag == 1){
			break;
		}
		for (i = 0; i < 4; i++){
			if (list[i] == 1){
				loadflag = 0;
				break;

			}

		}
		if (loadflag == 1){
			load(list[4], list[5], list[6], list[7]);
		}

	}
	for (i = 0; i < 4; i++){
		printf("%d ", reg[i]);

	}
	for (i = 0; i < 4; i++){
		printf("%d ", mem[i]);
	}

	printf("\n");

	
	return 0;
}


void load(int x1, int x2, int x3, int x4){

	// 4, 5 : memmory  6, 7: register
	int memorynum, regnum;
	memorynum = x1 * 2 + x2;

	regnum = x3 * 2 + x4;
	reg[regnum] = mem[memorynum];
	
	

}

문제 4


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int reg[4];
int mem[4];
//int reg1, reg2, reg3, reg4;
//int mem1, mem2, mem3, mem4;

void load(int, int, int, int);
void add(int x1, int x2, int y1, int y2);
void save(int x1, int x2, int y1, int y2);
void mul(int x1, int x2, int y1, int y2);



int main(void){

	int list[8];
	int i;
	int flag ;
	int loadflag;
	

	printf("Mackerel: 최다인, 김상렬 \n");
	for (i = 0; i < 4; i++){
		scanf("%d", &reg[i]);

	}
	for (i = 0; i < 4; i++){
		scanf("%d", &mem[i]);
			
	}


	
	while (1){

		flag = 1;
		loadflag = 1;



		for (i = 0; i < 8; i++){
			scanf("%d", &list[i]);

		}



		for (i = 0; i < 4; i++){
			if (list[i] == 0){
				flag = 0;
				break;
			}
		}
		if (flag == 1){
			break;
		}
		for (i = 0; i < 4; i++){
			if (list[i] == 1){
				loadflag = 0;
				break;

			}

		}
		if (loadflag == 1){
			load(list[4], list[5], list[6], list[7]);
		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 0)){
			add(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 1)){
			mul(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 0) && (list[3] == 1)){
			save(list[4], list[5], list[6], list[7]);

		}


	}//while 끝임
	for (i = 0; i < 4; i++){
		printf("%d ", reg[i]);

	}
	for (i = 0; i < 4; i++){
		printf("%d ", mem[i]);
	}

	printf("\n");


	return 0;

	//Fail입니다


}


void load(int x1, int x2, int x3, int x4){

	// 4, 5 : memmory  6, 7: register
	int memorynum, regnum;
	memorynum = x1 * 2 + x2;

	regnum = x3 * 2 + x4;
	reg[regnum] = mem[memorynum];
	
}
void add(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;
	
	reg[reg2] = reg[reg1] + reg[reg2];
	 
}
void save(int x1, int x2, int y1, int y2){

	int memorynum, regnum;
	memorynum = y1 * 2 + y2;

	regnum = x1 * 2 + x2;

	
	mem[memorynum] = reg[regnum];

}
void mul(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;

	reg[reg2] = reg[reg1] * reg[reg2];



}

문제 5


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int reg[4];
int mem[4];
int equ;
//int reg1, reg2, reg3, reg4;
//int mem1, mem2, mem3, mem4;

void load(int, int, int, int);
void add(int x1, int x2, int y1, int y2);
void save(int x1, int x2, int y1, int y2);
void mul(int x1, int x2, int y1, int y2);
void equal(int x1, int x2, int y1, int y2);



int main(void){

	int list[8];
	int i;
	int flag ;
	int loadflag;
	

	printf("Mackerel: 최다인, 김상렬 \n");
	for (i = 0; i < 4; i++){
		scanf("%d", &reg[i]);

	}
	for (i = 0; i < 4; i++){
		scanf("%d", &mem[i]);
			
	}


	
	while (1){

		flag = 1;
		loadflag = 1;



		for (i = 0; i < 8; i++){
			scanf("%d", &list[i]);

		}



		for (i = 0; i < 4; i++){
			if (list[i] == 0){
				flag = 0;
				break;
			}
		}
		if (flag == 1){
			break;
		}
		for (i = 0; i < 4; i++){
			if (list[i] == 1){
				loadflag = 0;
				break;

			}

		}
		if (loadflag == 1){
			load(list[4], list[5], list[6], list[7]);
		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 0)){
			add(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 1)){
			mul(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 0) && (list[3] == 1)){
			save(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 1) && (list[2] == 0) && (list[3] == 0)){
			equal(list[4], list[5], list[6], list[7]);
			printf("%d \n", equ);
		}


	}//while 끝임
	for (i = 0; i < 4; i++){
		printf("%d ", reg[i]);

	}
	for (i = 0; i < 4; i++){
		printf("%d ", mem[i]);
	}

	printf("\n");


	return 0;

	//Fail입니다


}


void load(int x1, int x2, int x3, int x4){

	// 4, 5 : memmory  6, 7: register
	int memorynum, regnum;
	memorynum = x1 * 2 + x2;

	regnum = x3 * 2 + x4;
	reg[regnum] = mem[memorynum];
	
}
void add(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;
	
	reg[reg2] = reg[reg1] + reg[reg2];
	 
}
void save(int x1, int x2, int y1, int y2){

	int memorynum, regnum;
	memorynum = y1 * 2 + y2;

	regnum = x1 * 2 + x2;

	
	mem[memorynum] = reg[regnum];

}
void mul(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;

	reg[reg2] = reg[reg1] * reg[reg2];



}
void equal(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;

	if (reg[reg1] == reg[reg2]){
		equ = 1;
	}
	else{
		equ = 0;
	}





}

문제 6

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int reg[4];
int mem[4];
int equ;
//int reg1, reg2, reg3, reg4;
//int mem1, mem2, mem3, mem4;

void load(int, int, int, int);
void add(int x1, int x2, int y1, int y2);
void save(int x1, int x2, int y1, int y2);
void mul(int x1, int x2, int y1, int y2);
void equal(int x1, int x2, int y1, int y2);
int beq(int x1, int x2, int x3, int x4);



int main(void){

	int list[8];
	int i,j,k;
	int flag ;
	int loadflag;
	int num;
	int temp;
	

	printf("Mackerel: 최다인, 김상렬 \n");
	for (i = 0; i < 4; i++){
		scanf("%d", &reg[i]);

	}
	for (i = 0; i < 4; i++){
		scanf("%d", &mem[i]);
			
	}


	
	while (1){

		flag = 1;
		loadflag = 1;



		for (i = 0; i < 8; i++){
			scanf("%d", &list[i]);

		}



		for (i = 0; i < 4; i++){
			if (list[i] == 0){
				flag = 0;
				break;
			}
		}
		if (flag == 1){
			break;
		}
		for (i = 0; i < 4; i++){
			if (list[i] == 1){
				loadflag = 0;
				break;

			}

		}
		if (loadflag == 1){
			load(list[4], list[5], list[6], list[7]);
		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 0)){
			add(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 1) && (list[3] == 1)){
			mul(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 0) && (list[2] == 0) && (list[3] == 1)){
			save(list[4], list[5], list[6], list[7]);

		}
		if ((list[0] == 0) && (list[1] == 1) && (list[2] == 0) && (list[3] == 0)){
			equal(list[4], list[5], list[6], list[7]);
			printf("%d \n", equ);
		}
		if ((list[0] == 1) && (list[1] == 0) && (list[2] == 0) && (list[3] == 0)){

			num = beq(list[4], list[5], list[6], list[7]);
			for (j = 0; j < num; j++){
				for (k = 0; k < 8; k++){
					scanf("%d", &temp);
				}
			}
			
		}



	}//while 끝임
	for (i = 0; i < 4; i++){
		printf("%d ", reg[i]);

	}
	for (i = 0; i < 4; i++){
		printf("%d ", mem[i]);
	}

	printf("\n");


	return 0;

	//Fail입니다


}


void load(int x1, int x2, int x3, int x4){

	// 4, 5 : memmory  6, 7: register
	int memorynum, regnum;
	memorynum = x1 * 2 + x2;

	regnum = x3 * 2 + x4;
	reg[regnum] = mem[memorynum];
	
}
void add(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;
	
	reg[reg2] = reg[reg1] + reg[reg2];
	 
}
void save(int x1, int x2, int y1, int y2){

	int memorynum, regnum;
	memorynum = y1 * 2 + y2;

	regnum = x1 * 2 + x2;

	
	mem[memorynum] = reg[regnum];

}
void mul(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;

	reg[reg2] = reg[reg1] * reg[reg2];



}
void equal(int x1, int x2, int y1, int y2){
	int reg1, reg2;

	reg1 = x1 * 2 + x2;
	reg2 = y1 * 2 + y2;

	if (reg[reg1] == reg[reg2]){
		equ = 1;
	}
	else{
		equ = 0;
	}

}
int beq(int x1, int x2, int x3, int x4){
	int num;

	num = x1 * 8 + x2 * 4 + x3 * 2 + x4;


	return num;
}
Retrieved from http://wiki.zeropage.org/wiki.php/CodeRace/2016/Mackerel
last modified 2021-02-07 05:22:56