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

Array בשפת C

Featured Replies

פורסם

יש לי תוכנה כזאת:


// 'Array, Do-While loop' C_Start 17 L.Sh.

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>

void main(void)
{
int index, vector[5];
float vec[]={1.5,2,3,4.1,5};

clrscr();
vector[0]=8; // 1-st array element.
vector[1]=2;
vector[2]=7;
vector[3]=5;
vector[4]=6; // 5-th array element.

index=0;
do{
printf("\n%6d %9.2f",vector[index], vec[index]);
}while(++index<5);
}

/*
Exercises : 1. Type array elements in inverse order.
( order in the array : 8 2 7 5 6
order in the screen: 6 5 7 2 8 )

2. Write loop that inverses order of the
elements in the array, type result.
( before inverse: 8 2 7 5 6
after inverse: 6 5 7 2 8 )

3. Type 'index++' instead '++index',
explain result.
*/

עכשיו התוכנה יחסית ברורה לי הבעיה הי בתרגיל 2

2. Write loop that inverses order of the

elements in the array, type result.

( before inverse: 8 2 7 5 6

after inverse: 6 5 7 2 8 )

אני לא מבין אפשר אפשר להפוך את זה כל מה שאני יודע זה שצריך להכניס עוד משתנה משו כמו TMP TEMP (זה לא עד כדי כך עקרוני)

אם מישהוא יודע או אולי יכול לפחות להביא רמז אני יודה לו מאוד

פורסם

פשוט תעשה לולאה על חצי האורך שתחליף את הראשון עם האחרון, אחרי זה את השני עם הלפני אחרון וכו..

פורסם
  • מחבר

את זה אני יודע אבל איך לעשות לולא?

לולאת while או for או do ??

פורסם

לולאת FOR:

for (i=0;i<2;i++)

{

tmp = array;

array=array[4-i];

array[4-i]=tmp;

}

או משהו כזה...

פורסם

מה זה משנה איזה לולאה? לכולם יש בדיוק אותו כוח חישוב

אתה יכול לעשות לולאת for שתעשה מה ש-while עושה וההפך

ארכיון

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

דיונים חדשים

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.