פורסם 2013 באפריל 912 שנים המשימה הייתה למיין מערך באורך n לפי השארית שלו בk מהקטן לגדול לדוגמא: עבור K=10 והמערך 64 28 79 46 13 התוצאה תהיה 79 28 46 64 13 אבל כשקימפלתי זה סידר אבל גם הוסיף לי מספר מוזר למערך למה זה קרה ??? הנה הקוד שלי #include <stdio.h> #include <stdlib.h> void swap (int *a,int *b) { int temp; temp=*b; *b=*a; *a=temp; return; } void sortmode(int a[],int n, int k) { int i,j; for (j=0;j<k;j++) { for (i=0;i<n;i++) { if ( (a%k) > (a[i+1]%k) ) { swap (a+i,a+i+1); } } for (i=0;i<10;i++) { printf("%d ",a); } printf("\n "); } return; } /*------------------------------------------------------------------------- The main program. (describe what your program does here) -------------------------------------------------------------------------*/ int main() { int a[10]={9,9,9,9,9,9,9,9,9,0}; int k=10,i; sortmode(a,10,k); return 0; } [\quote]
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.