عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 18-01-2013, 03:48 AM   #58

شيماء هلال

جامعي

 
تاريخ التسجيل: Jan 2013
التخصص: علم السلوك
نوع الدراسة: ماجستير
المستوى: متخرج
الجنس: أنثى
المشاركات: 1
افتراضي رد: الماتلاب: توفير مساعده قدر المستطاع مجاناً للطلاب MATLAB - Simulink

السلام عليكم ورحمة الله وبركاته
أشكر القائمين على هذا المنتدى الرائع، والأعضاء المشاركين فيه... بوركتم جميعا ونفع الله بعلمكم ونَفَعَكم...

في الحقيقة أواجه صعوبة في حلّ السؤاليْن التاليين، وسأكون خالصة الشكر لمن يمدّ يد العون:
أ. اكتب دالّة Scramble_One تستقبل كلمة string وتعطي للمستخدم نفس الكلمة لكن بحروف مبعثرة بشكل عشوائيّ، مع الإبقاء على الحرف الأول والأخير في مكانيهما (مثلا، إذا استقبلت الدالّة الكلمة
Scramble_One('smiley')
فستعطي الكلمة (simely) or (slmeiy) or...
"smile" فستعطي الكلمة "slmie").
هنا بعض التعليمات التي تسهّل الحلّ والتي يجب العمل بموجبها:
Copy the middle of the word (indices 2:end-1) into a temporary variable Temp_Word.
Use the function randperm(length(Temp_Word)) to generate scrambled indices.
Use the scrambled indices to scramble the Temp_Word.
Return the scrambled middle of the word (the variable Temp_Word) back into the original word such that the first and last letters are the same but all the middle is now scrambled.

Write a function Scramble_All "S" that receives a sentence in the form of a string and returns the same sentence with all the words scrambled.
Use the Scramble_One function to scramble each word at a time.
To locate the indices of each individual word in the sentence, first find the indices of the spaces and then use the indices between each two spaces as the indices of a word.
Pay special attention to the first and last words which might not be surrounded by spaces (one way to deal with this is to first add a space in the beginning and one at the end of S such that between each two spaces there is a word).
Use a loop to go over all the words in S.

b. Write a code that receives the name of a text file from the user, reads it into a matrix (call it Read_Text_File function), goes over it row by row in a loop, scrambles all the words of each row (using the Scramble_All function) and saves the scrambled version in a new text file.

بارك الله بكم...

 


التعديل الأخير تم بواسطة شيماء هلال ; 18-01-2013 الساعة 03:50 AM.
شيماء هلال غير متواجد حالياً