عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 28-05-2010, 12:06 PM   #551

Mr.Ahmad

عضو هيئة تدريس

الصورة الرمزية Mr.Ahmad

 
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

المشاركة الأصلية كتبت بواسطة خطى الجنان

السلام عليكم ورحمه الله وبركاته



.....



المشروع كالتالي :





Lab Final Project





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





عرض قائمه تتيح للمستخدم 4 خيارات _وبعد كل عمليه يٌسأل المستخدم ما اذا كان يريد عمليه اخرى ام لا _





1- اضافة بيانات طالب(رقم الطالب- درجته في الاختبار الاول 20-درجته في الاختبار الثاني20 -درجته في الاختبار النهائي 60)





ويُسأل المستخدم ما اذا كان يريد اضافة طالب اخر ام لا _ الحد الاقصى لعدد الطلاب 100_





-2 diminution array





-loop





2- حذف بيانات طالب بتحديد رقم الطالب المراد حذفه





shift up -





3- ادراج طالب ضمن القائمة بتحديد العنوان المراد اضافته فيه





shift down-





4- عرض بيانات الطلاب بعد كل عمليه





loop-





انشاء داله " function " لحساب معدل كل طالب وطباعة رقمه ومعدله .







...



Student ID | Test1 | Test2 | Final Exam
--------------------------------------------------------------
987654 | 15 | 16 | 55
234567 | 20 | 15 | 60
7654321 | 19 | 18 | 55
Another operation : 1
1)Add Student.
2)Remove Student
3)Insert Student
4)Display
Enter your choice: 1
Enter Student 4 ID :
456789
Enter Student 4 Test1 :
11
Enter Student 4 Test2 :
12
Enter Student 4 Final Exam :
40
another ? :0
Another operation : 1
1)Add Student.
2)Remove Student
3)Insert Student
4)Display
Enter your choice: 4



Student ID | Test1 | Test2 | Final Exam
--------------------------------------------------------------
987654 | 15 | 16 | 55
234567 | 20 | 15 | 60
7654321 | 19 | 18 | 55
456789 | 11 | 12 | 40
Another operation : 0
*
Student ID | Average
987654 | 86.00%
234567 | 95.00%
7654321 | 92.00%
456789 | 63.00%


ولو قدرت تطور البرنامج اكثر زي مثلا تضيف قدام الطالب الناجح
بدرجه 90 وفوق A و80 الى 89 B وهكذا حتى اذا وصلت درجة الطالب اقل من 60 يكون قدامه F
اتمنى يكون الحل بابسط صوره حتى اقدر افهمه
شاكره لك تعاونك وربي يفرج كربك زي ماتفرج كرب هالناس ولايحرمك الاجر
كود PHP:
#include <stdio.h>
#define SIZE 100

int add (int list[SIZE][4], int index);
int remove (int list[SIZE][4], int indexint ID);
void Display (int list[SIZE][4], int index);
void Insert (int list[SIZE][4], int indexint place);
void getAverage (int list[SIZE][4], int index);
char getGPA (float x);

int main () 
{
    
int list[SIZE][4];
    
int index = -1;
    
int select1,select2;
    do 
    {
        
printf("1)Add Student.\n2)Remove Student.\n3)Insert Student.\n4)Display.\n");
        
printf("\nEnter your choice: ");
        
scanf("%d",&select1);
        
printf("\n");
        switch (
select1)
        {
        case 
1:
            
index add(list,index);
            break;

        case 
2:
            
printf("Enter ID to Delete : ");
            
scanf("%d",&select2);
            
index remove(list,index,select2);
            break;

        case 
3:
            
printf("Enter Place to Insert : ");
            
scanf("%d",&select2);
            
Insert(list,index,select2);
            break;

        case 
4:
            
Display(list,index);
            break;
        }
        
printf("\nAnother operation : ");
        
scanf("%d",&select2);
        if (
select2 == 0) break;
    }
    while (
1);
    
printf("\n\nThank you !\n");
    
scanf("%d",&select1);
    return 
0;
}


int add (int list[SIZE][4],int index)
{
    
int select;
    if (
index == -1index 0;
    do
    {
    
printf("Enter Student %d ID : ",index 1);
    
scanf("%d",&list[index][0]);
    
printf("Enter Student %d Test1 : ",index 1);
    
scanf("%d",&list[index][1]);
    
printf("Enter Student %d Test2 : ",index 1);
    
scanf("%d",&list[index][2]);
    
printf("Enter Student %d Final Exam : ",index 1);
    
scanf("%d",&list[index][3]);
    
index++;
    
printf("nother ? : ");
    
scanf("%d",&select);
    if (
select == 0) break;
    } while (
1);
    return 
index;
}

int remove (int list[SIZE][4], int indexint ID)
{
    
int i;
    for (
i=0i<indexi++)
    {
        if (list[
i][0] == ID)
        {
            list[
i][0] = list[index 1][0];
            list[
i][1] = list[index 1][1];
            list[
i][2] = list[index 1][2];
            list[
i][3] = list[index 1][3];
            list[
index 1][0] = 0;
            list[
index 1][1] = 0;
            list[
index 1][2] = 0;
            list[
index 1][3] = 0;
            
printf("-> Done, deleted successfully. \n");
            
index--;
            return 
index;
        }
    }
    
printf("Not be removed! \n");
    return 
index;
}

void Display (int list[SIZE][4], int index)
{
    
int i;
    if (
index == -1)
    {
        
printf("There are no items to display! \n");
        return;
    }
    
printf("Student ID | Test1 | Test2 | Final Exam\n");
    
printf("----------------------------------------\n");
    for (
0indexi++)
    {
        
printf("%5d      |   %2d  |   %2d  | %5d \n",list[i][0],list[i][1],list[i][2],list[i][3]);
    }
    
printf("*\n");
    
getAverage(list,index);
}

void Insert (int list[SIZE][4], int indexint place)
{
    if ((
place-1) > (index-1)) 
    {
        
printf("Error \n");
        return;
    }
    
printf("Enter Student %d ID : ",place);
    
scanf("%d",&list[place-1][0]);
    
printf("Enter Student %d Test1 : ",place);
    
scanf("%d",&list[place-1][1]);
    
printf("Enter Student %d Test2 : ",place);
    
scanf("%d",&list[place-1][2]);
    
printf("Enter Student %d Final Exam : ",place);
    
scanf("%d",&list[place-1][3]);
}

void getAverage (int list[SIZE][4], int index)
{
    
int i;
    
float avg 0;
    
printf("Student ID | Average | GPA\n");
    
printf("-------------------------------\n");
    for (
0indexi++)
    {
        
avg = list[i][1] + list[i][2] + list[i][3];
        
printf("%5d      | %6.2f  | %c\n",list[i][0],avg,getGPA(avg));
    }
}

char getGPA (float x)
{
    if ((
>= 90) && (<= 100)) return 'A';
    if ((
>= 80) && (<= 89)) return 'B';
    if ((
>= 70) && (<= 79)) return 'C';
    if ((
>= 60) && (<= 69)) return 'D';
    if ((
>= 0) && (<= 59)) return 'F';
    else return 
'N';





بالتوفيق .

 

توقيع Mr.Ahmad  

 

سبحان الله وبحمد ,,, سبحان الله العظيم
الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه .
اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.

 

Mr.Ahmad غير متواجد حالياً   رد مع اقتباس