دوست عزیز می خواهید خانه های شطرنج رو اکی کنید کار نداره که .
یه دونه خانه سیاه هست یه دونه خانه سفید خب
این از دوبخش تشکیل شده یه سطر رو ستون .
بندازید تو یه حلقه for
و بعد هز بار به یه شر تو ماد دو ببنید باقی مانده صفر هست یا نه اگه صفر بود سفید باشه اگه نبود سیاه باشه همین .
- - - Updated - - -
دوست عزیز اینم کدش:
اینم اسکرین شات ازشکد:// shatranj.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "iostream" #include "conio.h" #include "windows.h" using namespace std; void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } int _tmain(int argc, _TCHAR* argv[]) { int row = 5 ; int cl = 5 ; int i = 0 ; int j = 0 ; int x,y=0; //int x = 0 ; for(i = 1; i<=row ;i++){ for(j = 1 ; j<=cl ; j++){ if(i%2!=0){ if((j%2)==0){ gotoxy((3*j)-3,(i*3)-3); cout<<"***"; gotoxy((3*j)-3,(i*3)-2); cout<<"***"; gotoxy((j*3)-3,(i*3)-1); cout<<"***"; }else{ gotoxy((3*j)-3,(i*3)-3); cout<<"OOO"; gotoxy((3*j)-3,(i*3)-2); cout<<"OOO"; gotoxy((j*3)-3,(i*3)-1); cout<<"OOO"; } }else{ if((j%2)!=0){ gotoxy((3*j)-3,(i*3)-3); cout<<"***"; gotoxy((3*j)-3,(i*3)-2); cout<<"***"; gotoxy((j*3)-3,(i*3)-1); cout<<"***"; }else{ gotoxy((3*j)-3,(i*3)-3); cout<<"OOO"; gotoxy((3*j)-3,(i*3)-2); cout<<"OOO"; gotoxy((j*3)-3,(i*3)-1); cout<<"OOO"; } } } } getch(); return 0 ; }
11-15-2014 2-43-05 AM.png





پاسخ با نقل قول