עבור לתוכן
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.

עזרה בכתיבת תוכנית ב סי

Featured Replies

פורסם

הנה:



#include <stdio.h>
#define MAXLEN 20
#define SIZE 3

typedef struct team
{
char name[20];
int scores;
int points;
}TEAM;

void main()
{
TEAM t[SIZE], tmp;
int i, j;
int a, b;

for(i=0;i<SIZE;i++)
{
printf("Insert Name For Team %d: ", i+1);
scanf("%s", t[i].name);
t[i].points=0;
t[i].scores=0;
}

for(i=0;i<SIZE;i++)
{
for(j=i+1;j<SIZE;j++)
{
printf("Game %s vs %s: ", t[i].name, t[j].name);
scanf("%d%d", &a, &b);
t[i].scores+=a;
t[j].scores+=b;
if(a==b)
{
t[i].points++;
t[j].points++;
}
else if(a>b)
t[i].points+=3;
else
t[j].points+=3;

}
}

for(i=0;i<SIZE;i++)
{
for(j=i+1;j<SIZE;j++)
{
if(t[j].points>t[i].points)
{
tmp=t[i];
t[i]=t[j];
t[j]=tmp;
}
}
}

printf("Team\tPoints\n");
for(i=0;i<SIZE;i++)
printf("%s\t%d\n", t[i].name, t[i].points);

for(j=0, i=1;i<SIZE;i++)
if(t[i].scores>t[j].scores)
j=i;
printf("\n\nTeams With Max Scores: \n");
for(i=0;i<SIZE;i++)
if(t[i].scores==t[j].scores)
printf("%s\n", t[j].name);
}

פורסם
  • מחבר

ok אני מנסה להפוך הקוד בלי שימוש במבנים כי עדין לא למדתי :kopfpatsch: אבל לא מצליחה אם אין בעיה אתה יכול להפוך :please:

ותודה

פורסם

הנה:


#include <stdio.h>
#include <string.h>
#define MAXLEN 20
#define SIZE 3


void main()
{
char name[SIZE][MAXLEN], tmp[MAXLEN];
int scores[SIZE];
int points[SIZE];
int i, j;
int a, b;

for(i=0;i<SIZE;i++)
{
printf("Insert Name For Team %d: ", i+1);
scanf("%s", name[i]);
points[i]=0;
scores[i]=0;
}

for(i=0;i<SIZE;i++)
{
for(j=i+1;j<SIZE;j++)
{
printf("Game %s vs %s: ", name[i], name[j]);
scanf("%d%d", &a, &b);
scores[i]+=a;
scores[j]+=b;
if(a==b)
{
points[i]++;
points[j]++;
}
else if(a>b)
points[i]+=3;
else
points[j]+=3;

}
}

for(i=0;i<SIZE;i++)
{
for(j=i+1;j<SIZE;j++)
{
if(points[j]>points[i])
{
strcpy(tmp, name[i]);
strcpy(name[i], name[j]);
strcpy(name[j], tmp);
a=points[i];
points[i]=points[j];
points[j]=a;
a=scores[i];
scores[i]=scores[j];
scores[j]=a;
}
}
}

printf("Team\tPoints\n");
for(i=0;i<SIZE;i++)
printf("%s\t%d\t%d\n", name[i], points[i], scores[i]);

for(j=0, i=1;i<SIZE;i++)
if(scores[i]>scores[j])
j=i;
printf("\n\nTeams With Max Scores: \n");
for(i=0;i<SIZE;i++)
if(scores[i]==scores[j])
printf("%s\n", name[i]);
}

עוד משהו?

פורסם
  • מחבר

תודה רבה :hi:, הפרעתי הרבה :s05:

פורסם

לא הרבה..

ארכיון

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

דיונים חדשים

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.