פורסם 2005 בינואר 1720 שנים יש לי תוכנה כזאת:// '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 (זה לא עד כדי כך עקרוני)אם מישהוא יודע או אולי יכול לפחות להביא רמז אני יודה לו מאוד
פורסם 2005 בינואר 1720 שנים פשוט תעשה לולאה על חצי האורך שתחליף את הראשון עם האחרון, אחרי זה את השני עם הלפני אחרון וכו..
פורסם 2005 בינואר 1720 שנים לולאת FOR:for (i=0;i<2;i++) { tmp = array; array=array[4-i]; array[4-i]=tmp; }או משהו כזה...
פורסם 2005 בינואר 1720 שנים מה זה משנה איזה לולאה? לכולם יש בדיוק אותו כוח חישובאתה יכול לעשות לולאת for שתעשה מה ש-while עושה וההפך
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.