Ali Hassan
اا مشرف سابق اا
- تاريخ التسجيل
- 30 سبتمبر 2011
- المشاركات
- 7,379
- المجموعة
- ذكر
- الدفعة الدراسية
- معلومة خاصة
- التخصص
- 0
حل آخرUsingthe “String Type” functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length.The program shouldthen scramble the word by moving the middle character to the beginning of the word and output the new word.
PHP:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string word; int size;
cout<<"Enter odd word : ";
while(!(word.size()%2==1)){cin>>word;}
size=word.size();
word=word[size/2]+word.substr(0,size/2)+
word.substr((size/2)+1,size-(size/2));
cout<<endl<<word<<endl; return 0;
}






