פורסם 2007 באוגוסט 118 שנים מחבר הבעיה הייתה FLUSHALL, לא יודע למה הרי זה לא קשור אלא אם אני עושה GETCH)( לא?בכל אופן הבעיה הבאה שלי, זה תמיד יוצא (לא נכנס לשום CASE)..int playGame(int gSize, char turn){ int x, y, xIndex=1, yIndex=1, win=0, mone=0; char nextA, arrow; x=40-(gSize*2)+2; y=13-gSize+1; while(win==0) { flushall(); gotoxy(0,0); printf("now: %c", turn); gotoxy(x,y); nextA=getch(); switch (nextA) { case '\0': arrow=getch(); switch (arrow) { // need to cheak boandris case 'H': // up if(yIndex==1) { ++yIndex; y+=2; } else { --yIndex; y-=2; } gotoxy(x,y); break; case 'P': // down if(yIndex==gSize) { --yIndex; y-=2; } else { ++yIndex; y+=2; } gotoxy(x,y); break; case 'K': // left if(xIndex==1) { ++xIndex; x+=4; } else { --xIndex; x-=4; } gotoxy(x,y); break; case 'M': // right if(xIndex==gSize) { --xIndex; x+=4; } else { ++xIndex; x+=4; } gotoxy(x,y); break; default: break; } break; // cheak turn and if empty(=22) case 'x': if(a[xIndex-1][yIndex-1]==22 && turn=='x') { a[xIndex-1][yIndex-1]=1; ++mone; turn='0'; } break; case '0': if(a[xIndex-1][yIndex-1]==22 && turn=='0') { a[xIndex-1][yIndex-1]=0; ++mone; turn='x'; } break; case '\x1b': return(0); // esc default: break; } win=cheakWin(gSize); if(mone==gSize^2 && win==0) { clrscr(); printf("There was no winner."); return(0); } } return(0);}
פורסם 2007 באוגוסט 118 שנים מחבר ישר אחרי זה הוא מנקה את המסך ומדפיס את הסוף..עריכה:סבבה הבעיה היא הIF בסוףהשורה הזו תקינה?if(mone==gSize^2 && win==0)
פורסם 2007 באוגוסט 118 שנים במקום nextA=getch();תנסה לעשות scanf או שאולי זה לא טוב לדרישות שלך אבל תראה אולי בגלל זה הבעיה.עריכה: איך אתה יודע שהבעיה ב if תראה את ההודעת שגיאה..
פורסם 2007 באוגוסט 118 שנים השורה הזו תקינה?if(mone==gSize^2 && win==0)האופרטור ^ לא עושה חזקה (אני מניח שזה מה שהתכוונת), אלא XOR.אם אתה רוצה להעלות בריבוע, פשוט תכפיל את gSize בעצמו.
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.