Forum » Programiranje » c++ problem
c++ problem
kretze ::
zdravo folk mene pa zanima kak bi v spodnji kodi napolnil polje??
//knjiznice #include <iostream> #include <stdlib.h> #include <string> #include<conio.h> #include<iomanip> using namespace std; void stevilo_studentov(int grade[][3], double st_ave[]) { for (int i = 1; i <= 3; i++) { double sum = 0; for (int j = 1; j <= 4; j++) sum = sum + grade[i - 1][j - 1]; st_ave[i - 1] = sum / 3; } } void sestevek_kvizov(int grade[][3], double quiz_ave[]) { for (int j = 1; j <= 4; j++) { double sum = 0; for (int i = 1; i <= 3; i++) sum = sum + grade[i - 1][j - 1]; quiz_ave[j - 1] = sum / 4; } } void prikazi(int grade[][3],double st_Ave[],double quiz_Ave[]) { using namespace std; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << setw(10) << "student" << setw(5) << " povprecje" << setw(15) << "kvizi\n"; for (int i = 1; i <= 4; i++) { cout << setw(10) << i << setw(5) << st_Ave[i - 1] << " "; for (int j = 1; j <= 3; j++) cout << setw(5) << grade[i - 1][j - 1]; cout << endl; } cout << "povprecje kvizov ="; for (int j = 1; j <= 3; j++) cout << setw(5) << quiz_Ave[j - 1]; } int main() { int grade[4][3]; double stAve[4] = { 1, 2, 3, 4 }; double quizAve[3] = { 70, 80, 90 }; stevilo_studentov(grade, stAve); sestevek_kvizov(grade, quizAve); prikazi(grade, stAve, quizAve); system("pause") return 0; }
kretze ::
napolnil sem polje samo nevem zakaj mi ne prikaže pravih rezultatov...ve kdo??
//knjiznice #include <iostream> #include <stdlib.h> #include <string> #include<conio.h> #include<iomanip> using namespace std; void stevilo_studentov(int grade[][3], double st_ave[]) { for (int i = 1; i <= 3; i++) { double sum = 0; for (int j = 1; j <= 4; j++) sum = sum + grade[i - 1][j - 1]; st_ave[i - 1] = sum / 3; } } void sestevek_kvizov(int grade[][3], double quiz_ave[]) { for (int j = 1; j <= 4; j++) { double sum = 0; for (int i = 1; i <= 3; i++) sum = sum + grade[i - 1][j - 1]; quiz_ave[j - 1] = sum / 4; } } void prikazi(int grade[][3],double st_Ave[],double quiz_Ave[]) { using namespace std; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << setw(10) << "student" << setw(5) << " povprecje" << setw(15) << "kvizi\n"; for (int i = 1; i <= 4; i++) { cout << setw(10) << i << setw(5) << st_Ave[i - 1] << " "; for (int j = 1; j <= 3; j++) cout << setw(5) << grade[i - 1][j - 1]; cout << endl; } cout << "povprecje kvizov ="; for (int j = 1; j <= 3; j++) cout << setw(5) << quiz_Ave[j - 1]; } int main() { int grade[4][3] = { {10,10,10}, {2,0,1}, {8,6,9}, {8,4,10} }; double stAve[4]; double quizAve[3]; stevilo_studentov(grade, stAve); sestevek_kvizov(grade, quizAve); prikazi(grade, stAve, quizAve); system("pause"); return 0; }
videc ::
A vas niso učili glede operatorjev & in *, pa prenašanje parametrov po referenci ali vrednosti?
videc ::
videc ::
Oziroma to:
http://www.cprogramming.com/tutorial/le...
http://www.tutorialspoint.com/cprogramm...
Pa kakšna knjiga o programiranju v C/C++ ne bo škodila. ;)
http://www.cprogramming.com/tutorial/le...
http://www.tutorialspoint.com/cprogramm...
Pa kakšna knjiga o programiranju v C/C++ ne bo škodila. ;)
Zgodovina sprememb…
- spremenilo: videc ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Qt/QML zajem podatkov iz podatkovne baze, dobim samo opise fieldov ter prazne vrednosOddelek: Programiranje | 1713 (1456) | windigo |
» | [Qt/C++]problem z Undefined reference na konstanti znotraj razredaOddelek: Programiranje | 2325 (1995) | phantom |
» | [C] Sinhronizacija procesovOddelek: Programiranje | 1126 (999) | Cvenemir |
» | [C] ProcesiOddelek: Programiranje | 965 (874) | Cvenemir |
» | [NALOGA][C] - Sortiranje učencevOddelek: Programiranje | 1314 (1167) | m4r3 |