C語言猜字遊戲

#include<iostream> 
#include<stdlib.h> 
using namespace std;

int main()
{
	while(1)
	{
		unsigned char ch[3]="",c;
		int j,sum = 0,t; 
	
		cout << endl 
			 << " *************************************************************** " << endl
			 << " ****************    猜   字   小   魔   術    ***************** " << endl
			 << " *************************************************************** " << endl;
		
		ch[0] = 0XB0;  
		
		for(int k=0;k<6;k++)
		{
			t = 0X1 << k; 
			cout << endl << endl 
				 << " *************************************************************** " << endl;
			j=0;
			for(int i=0;i<128;i++)
			{
				ch[1] = 0X80 | i;
				if(ch[1]&t) 
				{
					if(j%8==0)cout << endl;
					cout << "   " << ch << "   ";
					j++;
				}
			}
			cout << endl << endl 
				 << " *************************************************************** " 
				 << endl << endl;
			if(0 == k)
				cout << "  請記住其中的一個字,然後按Y或y " << endl << endl;
			else
				cout << "  請問你記住的字在這裏嗎?"<<endl 
					 << "  是請按Y或y,否則按N或n,遊戲繼續。"<< endl << endl;
			  
			cout << "  請選擇: " ;
			cin >> c ;
			if(c == 'Y' || c == 'y') {
				sum += 0x1 << k;
			}
			system("cls");
		}
		ch[1] = 0xc0 | sum;
		cout << endl
		     << " *************************************************************** " << endl << endl
		     << "                     你記住的字是:" << ch << endl <<endl
		     << " *************************************************************** " << endl << endl
		     << "  是否繼續?(按Y或y繼續) " << endl
		     << "  請選擇: " ;
		cin >> c ;
		if( !(c == 'Y' || c == 'y'))return 0; 
		system("cls");
	}
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章