بنوته فلسطينية
Well-Known Member
- تاريخ التسجيل
- 31 ديسمبر 2010
- المشاركات
- 107
- المجموعة
- أنثى
- الدفعة الدراسية
- 2010
- الكلية
- كلية العلوم
- التخصص
- احصاء-رياضيات
Write a function named removeExtraBlanks that takes two parameters: an array of characters (Sentence), and the number of characters in the array (Length), which is passed by reference. The function should remove all extra blanks in Sentence, i.e. for each two consecutive blanks, the function should remove the second blank character and decrement length accordingly. The function should also return the number of extra blanks removed from Sentence. Write a main program to test your function.
For example, If Length=10 and the content of Sentence before calling the function is:
[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[TD]7
[/TD]
[TD]8
[/TD]
[TD]9
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]
Then, after calling the function: Length=7 and Sentence should be as follows:
[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]
In addition, the function should return 3 (i.e. 3 blanks were removed)
محلول بالصفحات الي قبل





