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

ساعدوني في حل هذه المسالة

مغلق
بدأه طالب برمجة في 14 ديسمبر 2003 · 4 رد · 689 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ياريت حد يشرحلي طريقه حل هذي المساله

Write a C++ program to read name and one score of a class of n students. The program should do the following:

1. Assume the number of students in the class is n = 6.

2. Ask the user to enter name and score for each student in the class and store them in suitable arrays

3. Display the maximum score and all students who got the maximum.

4. Display the minimum score and all students who got the minimum.

5. Display the average score of the class.

Note: you should get the maximum score first and then you do a loop to get all students' names that got the maximum. The same you do for the minimum.

#2

تحتاج اخي الى تعريف مصفوفيتين و احدة للاسماء و اخرى للعلامات

float avg[6];
char name[6];

لايجاد المعدل الاكبر تعمل الكود التالي , و لأي طالب

float max;
char std [];
max = avg[0]
for(i=0;i<6;i++)
if a > max
max=a
cout<<" the max avg is <<max;

تم ايجاد اكبر معدل ... لمعرفة من هم الطلاب الذين حصلوا عليه ؟

for(i=0;i<6;i++)
if(max==avg)
cout<<name

للأسف ليس لدي و قت مع اني احب المساعدة كثيرا !!

#3

أعتقد هذي المسألة صعب تنحل بمصفوفتين وحدة string ووحدة int

كيف تربط بين الإسم الأول في مصفوفة الأسماء و الدرجة الأولى في مصفوفة الدرجات ؟؟؟؟

أقترح حلها بالسجلات struct بحيث يكون هناك رابط بين الأسماء والدرجات كالآتي:

struct students
{
	string name;
	float degree;
};

ثم تعرف مصفوفة من نفس نوع السجل

int main()
{
	students std[6];

}

وتعمل بعد ذلك تكرار تدخل به الأسماء والدرجات مثلاً:

الطالب 1 درجته 90

الطالب 2 درجته 95 وهكذا

أما المقارنة خذها من عند hasanofa

#4

مع إني كنت أتمنى إننا نشوف محاولاتك أول شئ ،، :(

#include<iostream.h>
#include<string.h>

void main()
{
	const int n=6; 
char name[n][20];
float score[n], max, min, avg;

cout<<"\n\n\n\t\tWELCOME IN MY PROGRAM FOR TALEEB-BARMAJAH ... ^_^ \n\n\n";
for(int i=0; i<6; i++ )
{
	cout<<"Enter name of student "<<i+1<<" in class :\n";
	cin>>name; 

	cout<<"Enter score of student "<<i+1<<" in class :\n";
	cin>>score; 

	cout<<endl;
}

max = score[0];
for(int j=1; j<6; j++ )
{
	if(score[j]>max)
  max=score[j];
}
cout<<"\n\n*************************************\n\n";
cout<<"students who got the maximum score ="<<max <<endl;
for(int m=0; m<6; m++ )
{
	if(score[m]==max)
  cout<<"name of student : "<<name[m]<<endl;
}

min = score[0];
for(int k=1; k<6; k++ )
{
	if(score[k]<min)
  min=score[k];
}

cout<<"\n\n*************************************\n\n";
cout<<"students who got the mainmum score ="<<min <<endl;
for(int l=0; l<6; l++ )
{
	if(score[l]==min)
  cout<<"name of student : "<<name[l]<<endl;
}

avg=(max + min )/n;
cout<<"\n\n*******************************\n\n";
cout<<"the average score of the class is :\n"<<max <<'+'<<min<<'/'<<n<<'=';
cout<<avg;

cout<<"\n\n Good Luck\n\n";
}

تم تعديل هذه المشاركة بواسطة العصاميه في 14 ديسمبر 2003 في 19:28

#5

ولا يهونون بقية الأخوان ،، :)

مع العلم بإنه ملاحظتي على برامجهم ،،

هو عدم إستخدام الـ

2- dimintional للإسم ،،

:)

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

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