반응형
#include <iostream>
#include <string.h>
#include <windows.h>

void color_red(void);
void color_green(void);
void color_blue(void);
void color_out(void);

struct MCU{
 unsigned char chip_type[10];
 unsigned int clock;
 unsigned int bit;
} type[10];

void main(void)
{
	using namespace std;
	unsigned int input; // int
	unsigned int COLOR_SELECT =0 ;
	
	cout << "몇개의 데이터를 입력하시겠습니까? : ";
	cin >> input;
	
	for(int i = 0; i < input; i++)
	{
		cout << "당신이 사용하는 칩 : ";
		cin >> type[i].chip_type;
		cout << "몇 클럭입니까? : ";
		cin >> type[i].clock;
		cout << "몇 비트 칩입니까? : ";
		cin >> type[i].bit;
		cout << endl;
	}
 
 	cout << endl;
 	
	for(i=0; i<input; i++)
	{
		if(COLOR_SELECT == 0) {color_red();}
		else if(COLOR_SELECT == 1) {color_green();}
		else if(COLOR_SELECT == 2) {color_blue();}
		
		cout << "["<<i+1<<"]" << "Your Chip : " << type[i].chip_type << " Processer" << "\n"; 
		cout << "["<<i+1<<"]" << "Chip's Clock : " << type[i].clock << " Clock" << "\n"; 
		cout << "["<<i+1<<"]" << "Chip's Bit : " << type[i].bit << " Bit" << "\n";
		cout << endl; COLOR_SELECT++;
		if(COLOR_SELECT == 3) {COLOR_SELECT = 0;}
	}
	cout << endl; color_out();
}
 
void color_red()
{
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8 | 5 );
}
void color_green()
{
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2 | 8 );
}
void color_blue()
{
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 1 | 8 );
}
void color_out()
{
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0 | 7 );
}


반응형

'프로그래밍 공부 > C++' 카테고리의 다른 글

- 구조체 총점,평균 구하기  (0) 2016.03.20
- 구조체 초기화  (0) 2016.03.20
- 문자열 비교  (0) 2016.03.20
- 승수 구하기  (0) 2016.03.20
- 구구단 출력  (0) 2016.03.20
Posted by 메가아재
,