עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

סיבות להפסקת ריצת תוכנית - C

Featured Replies

פורסם
  • מחבר

הבעיה הייתה 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);
}

פורסם

אז לפני שאתה נכנס ל-switch, תדפיס את הערך שקיבלת.

פורסם
  • מחבר

ישר אחרי זה הוא מנקה את המסך ומדפיס את הסוף..

עריכה:

סבבה הבעיה היא הIF בסוף

השורה הזו תקינה?

if(mone==gSize^2 && win==0)

פורסם

במקום

nextA=getch();

תנסה לעשות scanf

או שאולי זה לא טוב לדרישות שלך אבל תראה אולי בגלל זה הבעיה.

עריכה: איך אתה יודע שהבעיה ב if תראה את ההודעת שגיאה..

פורסם

השורה הזו תקינה?

if(mone==gSize^2 && win==0)

האופרטור ^ לא עושה חזקה (אני מניח שזה מה שהתכוונת), אלא XOR.

אם אתה רוצה להעלות בריבוע, פשוט תכפיל את gSize בעצמו.

פורסם

תשתמש בפונקציות כדי להפוך את הקוד שלך לברור יותר.

פורסם

תכופף יותר את הברכיים. זה יתן לך יציבות גדולה יותר בספיגת הנחתה.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.