זקוק לחוו"ד

זקוק לחוו"ד

אנו צריכים לבנות תוכנית פ ש ו ט ה ללא פונקציות ו/או פרוצדורות אשר תקבל מערך דו מימדי 3X3 תכניס לו מספרים ואחר כך תדפיס נניח כמה פעמים המספר 5 מופיע כתבתי את התוכנית, אבל.... אשמח לקבל חוו"ד #include <stdio.h> void main () { unsigned int x, y, counter = 0; scanf ("%d", value); //Creating the Box// int box [3] [3]; box [0][0] = 0; box [0][1] = 1; box [0][2] = 5; box [1][0] = 5; box [1][1] = 3; box [1][2] = 3; box [2][0] = 3; box [2][1] = 3; box [2][2] = 3; for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) if (box[x][y] == value) counter++; //Printing the result// printf("Number of times of value = %d", counter); }
 
בבקשה

| #include <stdio.h> void main () { unsigned int x, y, counter = 0; scanf ("%d", value); //Creating the Box// int box [3] [3]; box [0][0] = 0; box [0][1] = 1; box [0][2] = 5; box [1][0] = 5; box [1][1] = 3; box [1][2] = 3; box [2][0] = 3; box [2][1] = 3; box [2][2] = 3; for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) if (box[x][y] == value) counter++; //Printing the result// printf("Number of times of value = %d", counter); }
 
ניסיון שני...

#include <stdio.h> void main () { unsigned int x, y, counter = 0; scanf ("%d", value); //Creating the Box// int box [3] [3]; box [0][0] = 0; box [0][1] = 1; box [0][2] = 5; box [1][0] = 5; box [1][1] = 3; box [1][2] = 3; box [2][0] = 3; box [2][1] = 3; box [2][2] = 3; for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) if (box[x][y] == value) counter++; //Printing the result// printf("Number of times of value = %d", counter); }
 

vinney

Well-known member
המם...

scanf ("%d", value); זה לא מומלץ עדיף scanf ("%d", &value);​
 
או קיי וחוץ מז זה יעבוד??

זה יבצע את מה שרצית לעשות פשוט אין לי אפשרות לבדוק את זה
 

vinney

Well-known member
נראה לי שכן

רק רשמת שאתה צריך לקלוט את המערך, ואתה יוצר אותו... הא, וגם כשאתה עושה scanf, נהוג לפני זה לכתוב משהו, כדי שיהיה ברור שהתוכנית מחכה לקלט.
 
כן אבל...

אני יוצר מערך ואחר בודק כמה פעמים הספרה 5 נניח במה שנקלט מופיע במערך.. האם זה עובד כך?
 
למעלה