Forum » Programiranje » c++ programne deluje
c++ programne deluje
kretze ::
zdravo kaj ve kdo zakaj ta program ne deluje?? Error list ne zazna nobene napake
int main() #include <iostream> #include <stdlib.h> #include<fstream> #include <string> { string firstname; string lastname; double testscore; char grade = ' '; double sum = 0.0; int countt = 0; ifstream infile; ofstream outfile; infile.open("ch5_stdata.txt"); if (!infile) { cout << "connot open ouput file program terminates " << endl; return 1; } outfile.open("ch5_stdata.out"); infile >> firstname >> lastname; infile >> testscore; while (infile) { sum += testscore; countt++; switch(static_cast<int> (testscore)) { case 0: case 1: case 2: case 3: case 4: case 5: grade = 'F'; break; case 6: grade = 'D'; break; case 7: grade = 'C'; break; case 8: grade = 'B'; break; case 9: case 10: grade = 'A'; break; default: cout << "invalid score " << endl; } outfile << firstname << " " << lastname << " " << testscore << " " << grade << " " << endl; infile >> firstname >> lastname; infile >> testscore; } if (countt != 0) outfile << "class average " << sum / countt << endl; else outfile << "no data " << endl; infile.close(); outfile.close(); system("pause"); return 0; }
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [C++] problem z binarnimi datotekamiOddelek: Programiranje | 946 (811) | mallard |
» | uporaba C++ unmanaged kode v C#.NET projektuOddelek: Programiranje | 1900 (1623) | krho |
» | [c++] problem: pretvorba iz malih v velike crkeOddelek: Programiranje | 2123 (1770) | Makina |
» | [C] čuden izpis iz txt dat. na zaslonOddelek: Programiranje | 1666 (1403) | l0g1t3ch |
» | Loopy problemOddelek: Programiranje | 1469 (978) | snow |