Forum » Programiranje » c++ program
c++ program
kretze ::
dober dan mene pa zanima kako bi uredil program natancneje(static const student) v tej kodi da bi mi delovalo pa hvala za odgovore
/* Ime in priimek: Datum: BESEDILO NALOGE: */ //knjiznice #include <iostream> // vhodno-izhodni ukazi #include <stdlib.h> //standardni ukazi #include <string> // za la?je delo z nizi, veljavno le v C++ in ne v C# using namespace std; // uporaba imenskega prostora ni treba pisati std::ukaz class gradebook { private: string coursename; int grades[student]; public: static const int student = 10; static const int student = 10; gradebook(string name, int gradeaaray[]) { coursename = name; for (int i = 0; i < student; i++) grades[i] = gradeaaray[i]; } string getcoursename() { return coursename; } void displaymesage() { cout << "welcome ot the gradebook for" << getcoursename() << endl; } int getminimum() { int lowgrade = 100; for (int i = 0; i < student; i++) { if (grades[i] < lowgrade) lowgrade = grades[i]; } return lowgrade; } int getmaximum() { int highgrade = 0; for (int i = 0; i < student; i++) { if (grades[i]>highgrade) highgrade = grades[i]; } return highgrade; } double getAverage() { int total = 0; int average = 0; for (int i = 0; i < student; i++) total += grades[i]; average = total / student; } void ouputbartchar() { int freqenzy[11] = {}; for (int i = 0; i < student; i++) ++freqenzy[grades[i] / 10]; for (int j = 0; j < 11; j++) { if (j == 0) cout << "0-9"; else if (j == 100) cout << "100"; else cout << j * 10 << "-" << (j * 10) + 9 << ":"; for (int stars = 0; stars = freqenzy[j]; stars++) cout << "*"; cout << endl; } } void ouputgrades() { cout << "the grades are" << endl; for (int i = 0; i < student; i++) cout << "student" << i + 1 << grades[i]; } void procesgrade() { ouputgrades(); cout << "class average is " << getAverage() << "lowest grade is" << getmaximum() << "highest grade is " << getmaximum() << endl; ouputbartchar(); } }; int main() { int gradearray[gradebook::student] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 19 }; gradebook mygrade("c++ programming", gradearray); mygrade.displaymesage(); system("pause");// da is ogledam rezultate na zaslonu return 0; }
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [C] LPC1343 - UART - AT commandsOddelek: Programiranje | 1124 (1014) | JanezovJanez |
» | Qt/QML zajem podatkov iz podatkovne baze, dobim samo opise fieldov ter prazne vrednosOddelek: Programiranje | 1714 (1457) | windigo |
» | [Qt/C++]problem z Undefined reference na konstanti znotraj razredaOddelek: Programiranje | 2333 (2003) | phantom |
» | [c] Enaki datotekiOddelek: Programiranje | 1029 (889) | Spura |
» | [C++] Pridobivaje in brisanje le dolocenih znakovOddelek: Programiranje | 1334 (1128) | Gundolf |