1. 151.
    0
    using namespace std;
    4. include <iostream>
    5. include <iomanip>

    6. include <ctime>

    const int NUM_GRADES = 10;
    const int NUM_STUDENTS = 10;

    int findHighest (int []);
    int findLowest (int []);

    void printDatabase(const int a[][ NUM_GRADES ], char studentNames[] [ 5 ] );

    int main()
    {
    int student1[ NUM_GRADES ] = {56,67,83,81,70,84,94,64,68,86};
    int student2[ NUM_GRADES ] = {76,89,81,42,66,93,104,91,71,85};
    int student3[ NUM_GRADES ] = {65,69,91,89,82,93,72,76,79,99};

    char studentNames[NUM_STUDENTS][5] = {"Bob", "John", "Joe"};

    int database [ NUM_GRADES ][NUM_STUDENTS ];
    int i = 0;

    srand( time (0));

    for (i=1; i < NUM_GRADES; i++)
    student1[ NUM_GRADES ] = rand() % 50 + 50; //


    for (i=0; i < NUM_GRADES; i++)
    {
    database[ 0 ] [ i ] = student1[ i ];
    database[ 1 ] [ i ] = student2[ i ];
    database[ 2 ] [ i ] = student3[ i ];
    }

    printDatabase (database , studentNames);

    for (i=0; i < NUM_STUDENTS; i++)
    {
    cout << studentNames << "'s highest grade is: " << findHighest (student1) << endl
    << studentNames << "'s lowest grade is: " << findLowest (database [ i ]) << endl;

    }

    return 0;
    }

    int findHighest (int a[])
    {
    int highest = a[ 0 ];

    for ( int i = 1; i <= NUM_GRADES; i++)
    {if (a[ i ] > highest )
    highest = a[ i ];
    }

    return highest;
    }

    int findLowest (int a[] )
    {
    int lowest = a[ 0 ] ;

    for ( int i = 1; i <= NUM_GRADES; i++)
    if (a[ i ] < lowest )
    lowest = a[ i ];

    return lowest;
    }

    void printDatabase(const int a[][ NUM_GRADES ], char studentNames[] [ 5 ] )
    {
    cout << "Here is the grade databasenn" << setw(10) << "Name";

    {
    for (int n = 1; n <= NUM_STUDENTS; n++)
    {
    cout << setw( 4 ) << n;

    cout << endl;
    }

    for (int i = 0; i < NUM_STUDENTS; i++)
    {
    cout << setw (10) << studentNames[ i ];


    for (int j = 0; j < NUM_GRADES; j++)

    cout << setw ( 4 ) << a[ i] [j];

    cout << endl;
    }
    cout << endl;

    }
    //system("pause");
    }

    al amk yine insanlığım tuttu
    ···
   tümünü göster