مشاهدة النسخة كاملة : assignments


شذى الروح
11-10-2006, 02:56 AM
انه سجلت بذي الموقع كون تخصصي c++
والدكتوره معطتنا اسايمنت بحيث ماشرحت فياريت احد يشرح الي مابي حل الاسايمنت بس ابي طريقه الحل ويستعمل مثال ثاني بس رح احط انه الاسايمنت

اتمنى اجد تفاعل من قبلكم

problem1:
write c++
that prompts the user to enter their full name, street address,and city, state,and zipcode, and reads them string variables. display the strings as you would to address an envelope.

sample output:
Enter your name : Ahmed
Enter your street address : 506 Elm st
Enter your city ,state and zip : Hollywood ,CA 90210


Ahmed
506 Elm st
Hollywood ,CA 90210


problem2:
writ c++ program that prompts the user to enter his or her name and e-mail address.
Display the name and e-mail address in the format appropriate for an e-mail message.
The name should be in double quotes followed by the e-mail address enclosed in angle brackets.

sample output:

Enter your name : Abraham pearl
Enter your email address: apearl@aol.com
your e-mail should be addressed to :"Abraham pearl"<apearl@aol.com<

منطلق بطموحي
11-10-2006, 02:19 PM
السلام عليكم:

السؤال يحل بعدد من الطرق منها على سبيل المثال :

1. استعمال string
2.استعمال المصفوفات arrays
3.استعمال المؤشرات pointers
4.استعمال cin.get()

الخ ...

ما هي الطرق التي تم تغطيتها معكم ؟ بناء عليه يمكنني اعطاء بعض المفاتيح للحل

wafk

شذى الروح
11-10-2006, 09:25 PM
تسلم اخوي على تفاعلك


عطونا الاول الا اهو استعمال string

زالرابع cin.get

منطلق بطموحي
11-10-2006, 11:49 PM
هذا مثال بسيط:

#include<iostream>



using namespace std;


int main()**

char x[20];
char y[20];



cout<<"Enter your first name\n";

cin.getline(x,20,'\n');



cout<<"Enter the second name\n";

cin.getline(y,20,'\n');

cout<<"Your name is "<<x<<" "<<y<<endl;

return 0;
}

char x[20]; يعني مصفوفة من 20 حرف
cin.getline() امر نضع بداخله اولا المدخل x ثم العدد الاقصى للحروف ثم متى يتوقف و هنا عندما يجد فراغ
ما استعملناه يعتبر class و لكن غير مطلوب ان تفهمي ذلك في الوقت الحاضر

هذا احد الحلول و ليس الحل الوحيد

بالنسبة ل string ليست كل المترجمات compilers معرف بها هذه المكتبة ...جربي في نسختك ال C++

شذى الروح
12-10-2006, 12:31 AM
تشكر اخوي

بس بكلف عليك اشوي

ممكن توضح الشرح اكثر


احس روحي ضايعه مب فاهمه

سوري على الازعاج


وشكرا على تفاعلك


وردك السريع علي

شذى الروح
12-10-2006, 01:11 AM
سلام


اخوي الطريقه انه سويتها مادري صح او خطا

بس عقدتني الطريقه كون وايد معقده

فياريت تشرح الي طريقه اسهل بتعبك معاي بس ماعندي احد يشرح الي

انه سويت على حسب طريقتك مدري صح او خطا بس طلع الي 3 ارور

والبرنامج كالتالي

#include<iostream>
#include <string>
using namespace std;
int main()
**

char x[20];
char y[20];
char z[20];

cout<<"Enter your name \n";
cin.getline(x,20,'\n');

cout<<"Enter your street address \n";
cin.getline(y,20,'\n');

cout<<"Enter your city,stat and zip \n";
cin.get line(z,20,'\n');

cout<<"Your name is "<<x<<"your street address is "<<y<<"your city,stat and zip is"<<z>> endl;

return 0;
}


مادري اذا كان صح او لا


بس ياريت تساعدني