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

ما رأيكم بتقديم دروس في C++

مغلقرائج
بدأه تيمون في 22 أكتوبر 2003 · 139 رد · 9,278 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#26

السلام عليكم ،

اكمل على اللي قالته اختي طالبة ......

مثلا اذا نبغينا نستعمل الsubstr بالكود مالنا ........

كيف نستعمل substr ...؟؟؟؟؟؟؟؟؟؟؟؟

شوفوا مثلا :

منفرض شي اسمه word و هذا الword نوعه string ..... اعتقد تعرفون ليش ....

word = "ghfgdsjsks" ;

و يت و كتبت في الكود :

cout << word.substr(7,2 );

الsubstr ليها رقمين الرقم الاول (7) يحدد موقع الحرف اللي ابغي ابدأ منه ... بحيث ابدأ اعد من الصفرلين ما اوصل للرقم اللي حطيته وهو الرقم 7 ...

اما الرقم الثاني(2) فهو يحدد ليه كم حرف ابغي اخذ ...

بيطلع الناتج لينا sk .... ليش ؟؟؟؟؟؟؟؟؟:)

شوفوا لو بدينا انعد كل حرف موجود في جملة word بالترتيب بحيث نبدأ من الصفر بنوصل عند الحرف 7 و هو s .... عقب نبدأ نحسب من s حرفين لانا حطينا الرقم 2 ... فبيطلع لينا الناتج sk ...

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

#27

و عقب ما خلصنا شرح الوحده 3 ....

شكلي نسيت الواجب ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

الوحده 3 ... صفحة 149 .. السؤال 5 و السؤال 4 صفحة 151 ....

اذا صادفتكم اي مشكله اقدر اساعدكم فيها ...

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

#28

السلام عليكم ..

مشكور أخوي تيمون على الدروس .. يزاك الله ألف خير ..

وهذا حل المسألة ..

#include <iostream>

using namespace std;

int main ()

{

cout << " CS-101 Introduction to Programming and Problem Solving " <<endl;

cout << " Programming Assigment 1 " << endl;

cout << " Sally A. Student " << endl;

cout << " ID Number 431023877 " << endl;

cout << " Grade Summary " << endl;

cout << " Program Correctness: " << endl;

cout << " Quality of Style: " << endl;

cout << " Late Deduction: " << endl;

cout << " Overal Score: " << endl;

cout << " Comments: " << endl;

return 0;

}

تم تعديل هذه المشاركة بواسطة Haya في 26 أكتوبر 2003 في 21:15

#29

اقوووووووووووول تيموووووووووون

هذا الكود انا ماعرف شو الغلط اللي فيه

عقد بي الصراحة

بس لا تضحك علي...ادري به سخيف...

#include <iostream>

using namespace std;

string student;

int ID;

int main()

{

cout<<"plz enter your name and ID number"<<endl;

cin>>student>>ID>>endl;;

cout<<"you name is"<<student<<"and your ID"<<ID<<endl;

return 0;

}

يالله

انا في انتظاااار الجواب يا تيمون...لك مني صينية ديدان اذا حليته (اهداااء من اخوك بومبا)

خخخخخخخخخخخخ

تم تعديل هذه المشاركة بواسطة الطوفان في 26 أكتوبر 2003 في 21:30

#30

هذا حل السؤال رقم 4 صفحة 151.........

#include<iostream>

#include<string>

#include<cmath>

using namespace std;

const double pi = 3.14159;

void FindD( char k,float r ) ;

int main ()

{

char C ;

float m ;

cout << "Enter your data , A ( for area ) , "

<< endl << "D ( for diameter ) and C ( for circumference ) " << endl << endl ;

cin >> C >> m;

FindD( C,m);

return 0 ;

}

void FindD( char k,float r )

{

float y ;

string input ;

if ( (k == 'A') || (k == 'D') || ( k =='C'))

{

if ( k == 'A')

{

y = pi * ( pow(r,2));

input = "area";

}

else if ( k == 'D')

{

y = 2 * r ;

input = "Diameter";

}

else

{

y = 2 * pi * r ;

input = "Circumference" ;

}

cout << endl << "The " << input << " of a circle with radius "

<< r << " is " << y << " ." << endl << endl ;

}

else

cout << "Please check your data " << endl << endl ;

}

و هذا حلي .شو رايكم فيه؟؟؟؟؟؟؟؟؟؟؟

#31

السلام عليكم ، الطوفان ....

شخبارك ؟؟؟؟؟؟؟؟

شوف اول شي انته يوم ييت تكتب الكود عرفت شي اسمه string بس .... نسيت تكتب فوق #include<string>

و ثاني غلط انك يوم ييت تكتب cin كتبت endl و هذي ما يسير نكتبها مع cin ..

و هذا الكود مالك مصلح ......

#include <iostream>

#include<string>

using namespace std;

string student;

int ID;

int main()

{

cout<<"plz enter your name and ID number"<<endl;

cin>>student>>ID;

cout<<"you name is "<<student<<" and your ID "<<ID<<endl;

return 0;

}

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

#32

نسيت اخوي الطوفان ...... لا تنسى صينية الديدان .....

اوكيه .. تراني اترياها ........

اخوك تيمون

تم تعديل هذه المشاركة بواسطة تيمون في 27 أكتوبر 2003 في 00:08

#33

أخوي تيمون عندي واجب من ست أسئلة.. و تسليمهم يوم الأحد الياي.. و أبي أييب فيه 110 من 100 .. بس تكفى ساعدني و من عيوني صحن هريس يوصلك لين باب بيتك ع الافطار باجر!!

و هذا أول سؤال..

Write a function called “smallest3” that returns the smallest of three floating-point numbers. Also, write a function called “largest3” that returns the smallest of three floating-point numbers. In the main() function, use cin to enter 3 floating-point numbers and display the smallest and the largest.

و حليته بهالطريقة..لو في أي خطأ لو سمحت صححهم لي..

#include <iostream>

using namespace std;

void largest(float a , float b , float c);

void smallest(float d , float e , float g);

int main()

{

float a , b, c ;

cout << " please enter 3 numbers "<< endl;

cin >> a >> b >> c ;

cout << " The largest number is " ;

largest (a,b,c);

cout << endl;

cout << " The smallest number is " ;

smallest(a,b,c) ;

cout << endl;

return 0;

}

void largest(float a , float b , float c)

{

if ( a > b )

if( a > c )

cout << a ;

else

cout << c ;

else if ( b > c )

cout << b ;

else

cout << c ;

}

void smallest ( float d, float g , float e )

{

if ( d< g )

if( d < e )

cout << d ;

else

cout << e ;

else if ( g < e )

cout << g ;

else

cout << e ;

}

#34

السلام عليكم.....أخوي تيمون أنا حليت مسألة رقم 4 بعد ...صفحة....149.....

و إن شاء الله يكون صح ...يعني شذي حليت كل الأسئلة المطلوبه للحين........خخخخ....

#include<iostream>

#include<cmath>

using namespace std;

void solution(float ,float , float ); // d for delta

int main()

{

float a,b,c;

cout<<"Enter three numbers to find the solution"<<endl;

cin>>a>>b>>c;

solution(a,b,c);

return 0;

}

void solution(float a, float b, float c)

{

float d , x1 , x2,k;

d=(b*b-4*a*c);

if(a==0)

{

x1=-c/b;

cout<<" if a=0 then the solution is"<<x1<<endl;

}

else

{

if(d>0)

{

x1=((-b+sqrt(d))/2*a);

x2=((-b-sqrt(d))/2*a);

cout<<"we have two solutions..the first solution is"<<x1<<" the second solution is"<<x2<<endl;

}

else if(d==0)

{

k=(-b/2*a);

cout<<"we have one solution and the solution is"<<k<<endl;

}

else

{

cout<<" there is no solution"<<endl;

}

}

}

#35

السلام عليكم اختي أشواق ....... مبروك عليش الشهر ...

الكود مالش صح بس هو بالسؤال ما طلب void function لانه قالشwrite a function that return و مدام مكتوب فيها return فلازم ما نكتبها void نكتبها اي شي ثاني مثل float ...

و هذا هو الكود الصح ...

#include <iostream>

using namespace std;

float largest(float a , float b , float c);

float smallest(float d , float e , float g);

int main()

{

float a , b, c ;

cout << " please enter 3 numbers "<< endl;

cin >> a >> b >> c ;

cout << " The largest number is " <<largest (a,b,c) << endl;

cout << " The smallest number is " <<smallest(a,b,c) << endl;

return 0;

}

float largest(float a , float b , float c)

{

if ( a > b )

if( a > c )

return a ;

else

return c ;

else if ( b > c )

return b ;

else

return c ;

}

float smallest ( float d, float g , float e )

{

if ( d< g )

if( d < e )

return d ;

else

return e ;

else if ( g < e )

return g ;

else

return e ;

}

بس اقول اشواق اتراني اتري الهريس باشر اوكيه ......

اخوش تيمون

#36

مشكور أخوي تيمون على التصحيح.. بس تريا علينا شوي.. حل الخمس الباجيين و إن شاء الله بيوصلك الهريس..

هذا السؤال الثاني..

Because of the high price of gasoline, drivers are concerned with the mileages obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gasoline used for each tankful. Develop a C++ program that will input the miles driven and gasoline used for each thankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls.

A sample from the program’s execution:

Enter the gallons used (-1 to end): 12.8

Enter the miles driven: 287

The Miles / Gallon for this tank was 22.4219

Enter the gallons used (-1 to end): 10.3

Enter the miles driven: 200

The Miles / Gallon for this tank was 19.4175

Enter the gallons used (-1 to end): 5

Enter the miles driven: 120

The Miles / Gallon for this tank was 24

Enter the gallons used (-1 to end): -1

The overall average Miles/Gallon was 21.6014

Press any key to continue

و هذا حلي...بس ابيك تشوفلي أخطائي... و مشكور مرة ثانية أخوي..

#include <iostream>

using namespace std ;

float average;

int main ()

{

float x , y ;

float total= 0, count = 0;

cout <<" Please enter gallon(s) " << endl;

cin >> x ;

while ( x != -1 )

{

cout << "Please enter miles " << endl;

cin >> y ;

cout <<" The Miles / gallons for this tank is " << y / x<< endl;

total = total + (y/x) ;

cout <<" Please enter gallon(s) " << endl;

cin >> x ;

count++ ;

}

average = total/ count;

cout << "The overall average for Miles / gallons was "<< average << endl;

return 0;

}

#37

اختي اشواق انتي حلش صح 100% بس اذا كنتي تبغينه يطلع نفس المثال اللي الاستاذ عطاكم بالضبط اكتب شذي الكود :

#include<iostream>

using namespace std ;

int main ()

{

int count = 0 ;

float total = 0 ;

float m , g ;

cout << "Enter the gallons used (-1 to end): " ;

cin >> g ;

while ( g != -1)

{

cout <<"Enter the miles driven: ";

cin >> m ;

cout <<"The Miles / Gallon for this tank was " << (m/g)<<endl << endl;

total = total + (m/g);

count++ ;

cout << "Enter the gallons used (-1 to end): " ;

cin >> g ;

}

cout <<"The overall average Miles/Gallon was " << (total/ count)<< endl;

return 0 ;

}

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

#38

والله ما تقصر أخوي تيمون... الحين ضمنت 30 درجة من ال110!!! بس و الله مستحية منك أخوي...أحس تعبتك واااايد ويااااي...بس شو نسوي،اتحملنا شوية!!

و هذا السؤال الثالث..

The process of finding the largest and smallest numbers (i.e. the maximum and minimum of a group of numbers) is used frequently in many computer applications. Write a C++ program that reads name and score of a class of 10 students and calculates and prints the following:

1. The largest score in the class and who got it

2. The smallest score in the class and who got it

3. The average score of the class

A sample from the program’s execution:

Enter name and score of student # 1: aaa 85

Enter name and score of student # 2: bbb 90

Enter name and score of student # 3: ccc 80

Enter name and score of student # 4: ddd 92

Enter name and score of student # 5: eee 75

Enter name and score of student # 6: fff 87

Enter name and score of student # 7: ggg 93

Enter name and score of student # 8: hhh 70

Enter name and score of student # 9: iii 91

Enter name and score of student # 10: jjj 84

The maximum score is 93 and the student ggg got it.

The minimum score is 70 and the student hhh got it.

The average score is 84.7

Press any key to continue

و هاي حلي....

#include <iostream>

#include<string>

using namespace std;

float average;

int main()

{

float scoure, count, total, max , min,average ;

string name, MAX, MIN;

count = 1 ;

total= 0;

average = 0;

max = 0;

min = 1000;

while ( count <= 10 )

{

cout<<" Enter name and score of student # " << count << ": " ;

cin >> name >> scoure ;

total=total + scoure;

count++;

if ( scoure >= max)

{

MAX= name;

max = scoure;

}

if ( scoure <= min )

{

MIN= name;

min = scoure;

}

}

cout << " The maximum scoure is " << max << " and the sudent " << MAX << " is got it " << endl;

cout << " The minimum scoure is " << min << " and the sudent " << MIN << " is got it " << endl;

average = total/10;

cout << " The average scoure of the class is " << average << endl;

return 0;

}

و أخوي أبي أطلب منك تفهمنا على الinfile و كيف نسوي فايل ..أنا مو فاهمة شي بهالسوالف..بس الله يسامح أستاذناّ!!!

#39

ما شا الله عليش طالبة الله يوفقكج ..

و بصراحة كودج ما عليه كلام ...

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

#40

أول مرة أسوي كود صح!!!

أكيد صح!!؟؟ و الله شاكة في نفسي!!

مشكور أخوي تيمون...

السؤال الرابع...

When there are many students in the class, the previous problem is not practical because the user has to enter all names and scores from the keyboard, which is tedious work. A better solution is to allow your program to read students’ names and scores from a file and either to display the results on the screen or to store the results in another file.

Rewrite the previous program in C++ and instead of reading the students’ names and scores from the keyboard, read them from a file. You should create a file called “studentsScores.dat” and initialize it with the following data where the first number at the top of the file is the number of students in the class.

studentsScores.dat

10

aaa 85

bbb 90

ccc 80

ddd 92

eee 75

fff 87

ggg 93

hhh 70

iii 91

jjj 84

مشكلتي هاذي...ما أعرف خطوات عمل فايل....ممكن تشرحلي..و إن شاء الله بحاول أحلها لين باجر...

#41

كود المسأله مالج الثالث صح بعد بس اذا كنتي تبغينها تطلع نفس المثال اللي الاستاذ عاطنكم ...

اكتبي الكود شذي :

#include <iostream>

#include<string>

using namespace std;

float average;

int main()

{

float scoure, count, total, max , min,average ;

string name, MAX, MIN;

count = 1 ;

total= 0;

average = 0;

max = 0;

min = 1000;

while ( count <= 10 )

{

cout<<"Enter name and score of student # " << count << ": " ;

cin >> name >> scoure ;

total=total + scoure;

count++;

if ( scoure >= max)

{

MAX= name;

max = scoure;

}

if ( scoure <= min )

{

MIN= name;

min = scoure;

}

}

cout << "The maximum scoure is " << max << " and the sudent " << MAX << " is got it " << endl;

cout << "The minimum scoure is " << min << " and the sudent " << MIN << " is got it " << endl;

average = total/10;

cout << endl <<"The average scoure of the class is " << average << endl;

return 0;

}

اما بالنسبه للملفات :

اول شي نحنا اذا كنا نبغي نقرأ بيانات من file او نطلع البيانات الموجودة عدنا في الفايل ...

لازم نكتب بالبداية #include<fstream >

و هذي معناها مصدر الملف وهم نوعين ifstream و هذا اللي بتكون البيانات موجوده فيه وانا بقراها ...

ومعناها in file stream ... اما الثاني ofstream و هذا اللي بكتب فيه البيانات الموجوده عنديه .. و معناها out file stream ....

فمثلا انا ابغي افتح ملف موجود عنديه في الكمبيوتر و مكتوب فيه ارقام ابغي اطلع هذي الارقام الموجوده على الشاشه السودا ....... كيف بكتب الكود ؟؟؟

نراكم في الحلقة القادمه ........

ههههههههههههههههههههههههه .....

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

#42

اسمحي لي اختي شوق بس فيييييييييييه ارررررررررررقاد .... و برقد

اوكييييييييييييييييه ......

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

تم تعديل هذه المشاركة بواسطة تيمون في 27 أكتوبر 2003 في 01:11

#43

آسفة ع الازعاج أخوي... و مشكوور على الشرح!!

باجر إن شاء الله بسأل الاسئلة الباقية!!!!

#44

Hi Mr.Timon your idea is very nice and thank you for that but can you explain about advance C++ "Object oriented and Structure " it is very intersted for me and maybe for other ,,,

If you can do that please tell us

I need your help,,

thank you again,

#45

السلام عليكم اخوي hilal xp

آآآآآآآآآآآآآآآسف بس اسمحلي ما اقدر اساعدك بهذا الموضوع ....

لاني بعدي توني ادرس البرمجه بعديه بprogramming 1

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

#46

اما بالنسبه للملفات :

اول شي نحنا اذا كنا نبغي نقرأ بيانات من file او نطلع البيانات الموجودة عدنا في الفايل ...

لازم نكتب بالبداية #include<fstream >

و هذي معناها مصدر الملف وهم نوعين ifstream و هذا اللي بتكون البيانات موجوده فيه وانا بقراها ...

ومعناها in file stream ... اما الثاني ofstream و هذا اللي بكتب فيه البيانات الموجوده عنديه .. و معناها out file stream ....

فمثلا انا ابغي افتح ملف موجود عنديه في الكمبيوتر و مكتوب فيه ارقام ابغي اطلع هذي الارقام الموجوده على الشاشه السودا ....... كيف بكتب الكود ؟؟؟

اول شي لازم اكتب فوق عند الinclude

#include<fstream>

ifstream infile ;

يعني انا فرضة الملف اللي بتكون فيه البيانات و اللي بتعامل وياه في الكود infile ... و عقب ما فرضت و خلصت لازم شو اسووووي ؟؟؟

لازم افتح الملف فبكتب ....

infile.open("Data.dat")

تكتبونها شذي اذا كان الفايل اللي بتفتحونه موجود في نفس المكان اللي انتو خزنتوا فيه الكود مالكم ... اما اذا كان الفايل في مكان مختلف فلازم تحددون بالضبط وين موقعه ....

و عقب ما فتحت الملف يبغي لي اقرأ البيانات من الفايل فافرض مثلا شي اسمه number و هو بحيث اعرفه على انه integer or float or ........ etc

و يوم بي اقرأ البيانات او من الملف بالتعامل وياها مثل ما اتعامل مع الcin بس بدال ما اكتب الcin اكتب اسم الملف اللي انا عرفته بالبداية و هو infile ..

فبكون الكود كالتالي :

infile >> number ;

و هذا مثال بسيط على اللي قلته يقرأ البيانات الموجوده في الفايل و عقب ايطلع مجموعهم :

#include<fstream>

#include<iostream >

using namespace std ;

int main()

{

int num ;

infstream in ;

in.open("Data.txt")

in >> number ;

while(in)

{

sum =sum + num ;

in >> number ;

}

cout << "The sum of the number in file " << sum << endl ;

return 0 ;

}

ملاحظه : قبل ما تشغلون هذا البرنامج اتبعوا التالي

1. اضغطوا على file بعدين new ثم اختاروا من الtexts file ..

2. بتطلع ليكم صفحه فاضيه اكتبوا فيها الارقام اللي تبغونها مثل شي :

23

45

667

77

55

3. اغلقوا الفايل اللي فتحتونه مع حفظ التغيرات ....

اوكيييييييييييه ....

و اي شي ما فهمتونه من الكود اللي كتبته خبروني وانا بقول ليكم ليش كتبته ...

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

#47

السلام عليكم

مشكور تيمون عالجهد الطيب والله يبارك في حسناتك في هالشهر الفضيل إن شاء الله

بس حبيت اطلب منك جواب السوال رقم 4 صفحه 151

لاني مافهمت الجواب اللي محطوط امس

#48

السلام عليك اخوي طالب برمجة ....

هذا هو جواب السؤال اللي طلبته ... و هذا الحل مب انا اللي حالنه حالتنه الاخت haya ...

#include <iostream>

#include<iomanip>

using namespace std;

int main()

{

float d;

float c;

float a;

const double PI=3.14159;

float r;

r = 6.75;

a = 2 * PI * r * r;

c = 2 * PI * r;

d = 2 * r;

cout << " The arae of circle is " <<setprecision(5) << a << endl;

cout << " The ci of circle is " << setprecision(5)<<c << endl;

cout << " The d of circle is " << setprecision(5)<<d << endl;

return 0 ;

}

و الحل مالها صحيح 100 % ...

اخوك تيمون

#49

الله haya حلها سهل واااااااااااااايد..........خطيرة ...شطوره....

أنا معقدة أحل المسائل بطريقة غير......خخخخخخخخخخخ......

#50

السلام عليكم

عندي سؤال بخصوص if

احيانا نستخدم if اكثر من وحده بدون ما انحطelse

ومرات نستخدم else مع if

شو الفرق وهل يوثر هالشي في الكود؟

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

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…