الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سؤال في++ c

مغلق
بدأه IT girl في 17 أكتوبر 2003 · 7 رد · 945 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله

عندي سؤال..

The data type string is not one of the built-in data types of the C++. Many

applications are based on the string manipulations such as MS Word. Write a C++ program to display the following menu and allow the user to perform one of the following option

Print the length of the string1

Print the location of the first occurrence of a specific string2

Print each character in a line3

.Print how many times a specific string exist 4

5. Exit

تم تعديل هذه المشاركة بواسطة IT girl في 17 أكتوبر 2003 في 23:38

#2

شو السالفه .. ما اشوف اي مساعده..

#3

السلام عليكم

شرح مفصل عن ال string موجود في موقع msdn.com وهناك ادخلي الى المكتبة library وتستطيعين ايجاد كل ال methods and overloaded operators

#4

السلام عليكم,

من أجل ما تريد يمكنك استعمال القسم string الموجود في المكتبة <string> وهده تمنحك جميع الدوال الخاصة الكلمات . ولبرمجة دالك يمكنك أن تقوم كالتالي :

string str; لتنشأ str من نوع string

بعد هدا يمكنك استعمال الدوال str.length هده تعطيك طول الكلمة.

str.substr توجد قطعة كلمة وسط أخرى

str.at تعطيك الحرف في موقع ما

وكما أنه هناك دوال أخرى كثيرة.

#5

thanks...

#6

اهلين it girl

شوفي هذا الكود ........

#include<iostream>

#include<string>

using namespace std ;

int main ()

{

bool Start = true;

int T=0 , count = 0, num ;

string word ;

string search ;

while(Start)

{

cout <<"*************************************************************************" << endl;

cout <<"1.Print the length of the string" << endl;

cout <<"2.Print the location of the first occurrence of a specific string" << endl;

cout <<"3.Print each character in a line" << endl;

cout<<"4.Print how many times a specific string exists" << endl;

cout <<"5.Exit"<<endl;

cout<<"*************************************************************************" << endl;

cout <<"Select your choice: ";

cin>> num ;

if ( num != 5 )

{

cout<<"Enter a string: ";

cin >> word ;

}

if ( num == 1 )

cout<<"The length of the string is: " <<word.length() << endl ;

else if ( num == 2 )

{

cout <<"Enter a string to be searched : ";

cin >> search ;

if ( word.find(search) > 2000 )

cout <<"The string " << search << " is not existing" <<endl;

else

cout <<"The first occurrence of the string gas exists in location number "

<< word.find(search)<<endl;

}

else if( num == 3 )

while(count<=word.length ())

{

cout << word.substr (count,1)<< endl;

count++;

}

else if ( num == 4 )

{

cout <<"Enter a string to be searched : ";

cin >> search ;

if ( word.find(search) > 2000 )

cout <<"The string " << search << " is not existing" <<endl;

else

{

while(count < word.length())

{

if ( word.substr(count,search.length())== search )

T++;

count++ ;

}

cout <<"The string " << search << " exists " << T <<" times "<< endl;

}

}

else if ( num == 5 )

Start = false ;

count = 0 ;

}

cout <<"Thanks for using the program..."<<endl;

return 0 ;

}

اخوك تيمون .....

#7

ما شاء الله عليك أخوي تيمون...........أنته توب في هالسوالف.........

#8

تيمون

تســــــــــــــــــــــــلم

هذا الموضوع مغلق.

مواضيع مشابهة