السلام عليكم
في الحقيقة انا محتاج كود لهذا البرنامج واتمنى ان تساعدوني
اغتنموا الفرصة وبادروا بفعل الخير في هذا الشهر الكريم
طبعا المطلوب في هذه الصفحة هنا
جزاكم الله خير
يالله مع السلامة
السلام عليكم ,,,,
ياأخ alr7al2002 ... لو تكرمت وحاولت اختصار السؤال الى نقطة معينة في البرنامج أو عدة نقاط .. يكون أفضل ...
لأن محاولة اقتلاع الحل من وسط هذه " العريضة" سيأخذ وقتا أطول ,,, فيمكنك ان تساعد نفسك أكثر في أن تجد الحل الوافي يتقسيم المشكلة الى نقاط ,,, وبالتوفيق باذن الله ,,,
السلام عليكم
البرنامج يعمل مع ملفات txt عمل sort ل string
البرنامج يستخدم insert sort
******************************************************************/
// Function swap: interchanges values of two float variables
// Parameters: pointers to two variables
// Returns: nothing
void swap(int *a, int *b)
{int temp;
temp= *a;
*a= *b;
*b=temp;
}
/******************************************************************/
// Function sort_table: sorts float numbers into increasing order
// Algorithm used: Selection sort (modified)
// Parameters: float type array, number of elements in array
// Returns: nothing
void sort_table(int number[], int count)
{int size, maxsub;
for(size=count; size>1; size--) // Find largest number, move it to end of array
{
maxsub=findmax(number,size); // Reduce size of array by one.
if(maxsub!= size-1) swap(&number[size-1],&number[maxsub]);
}}
طبعا المستخدم يقوم بادخال الملف الذي يريد قراءته وايضا يدخل الملف الذي يريد كتابته
البرنامج وظيفته ان يقوم بقراءة الملف المدخل ويعمل سورت ومن ثم الكتابة في ملف اخر
هذه الجملة لم افهمها
It should issue an appropriate error message if an incorrect number of arguments are supplied or one of the files cannot be opened.
int main ( int argc, char *argv[] )
هذا المطلوب ولكن بلانجليزي
Access the command line arguments, open the input and output files, call input_strings,sort, and output_strings, and then close the input and output files.
طبعا هذه وظيفة الادخال
int input_strings ( FILE *file, char strings[MAX_N_STRINGS][MAX_STRING_LENGTH] )
Read the input strings from the stream file, placing them in the array of strings strings, and return the number of strings read.
يجب استخدام امر strcmp
void sort ( int n_strings, char unsorted[MAX_N_STRINGS][MAX_STRING_LENGTH], char sorted[MAX_N_STRINGS][MAX_STRING_LENGTH] )
Sort the strings in the array of strings unsorted, returning the result in the array of strings sorted. The unsorted array should not be modified.
void output_strings ( int n_strings, FILE *file, char strings[MAX_N_STRINGS][MAX_STRING_LENGTH] )
Write the strings from the array of strings strings to the stream file.
Use #define commands to specify values for MAX_N_STRINGS and MAX_STRING_LENGTH:
MAX_N_STRINGS
5000
MAX_STRING_LENGTH
100
هذه طريقة عمل السورت بس الحقيقة لم افهم لذلك لم استطع ترجمتها
To sort strings by manipulating pointers to the strings: create an array of pointers to strings: char *string_pt[MAX_N_STRINGS]. initialize the values of the elements of this array with the addresses of each string in the array of strings to be sorted. (strings[index] is a pointer constant pointing to the index string in the array of strings. If this is done correctly, *string_pt[index] with point to the index string in the array of strings.) When implementing the insert sort algorithm, the two arguments of strcmp should be string pointers pointing to the strings to be compared. If a swap needs to be performed, swap the pointers in the array of pointers, not the strings in the array of strings. When the insert sort finishes, the pointers will be ordered correctly but the elements of the unsorted array will be unchanged. As a last step, use strcpy to copy the strings pointed to by the pointers in string_pt to the sorted array of strings.
اين الردوديا اخوان
مع السلامة
اين الردوديا اخوان
السلام عليكم
اين الردود يا اخوان
الرجاء مساعدتي
مع السلامة
هذا الموضوع مغلق.