Feribotul: suma + persoane (fisier)
Enuntul complet in imaginea atasata mai jos
Ideea
Rezolvare (C++)Functia Suma(masini, persoane) wrote:Returneaza incasarea UNEI calatorii: masini*x + persoane*y.
Code: Select all
#include <iostream>
#include <fstream>
using namespace std;
int Suma(int m, int p, int x, int y) {
return m * x + p * y;
}
int main() {
int n, x, y;
ifstream f("bac.txt");
f >> n >> x >> y;
int total = 0, pers = 0;
for (int i = 0; i < n; i++) {
int m, p;
f >> m >> p;
total += Suma(m, p, x, y);
pers += p;
}
cout << total << endl << pers;
return 0;
}Intrebari? Postati mai jos.Verificare exemplu wrote:n=3, x=50, y=20: (2,10)->300; (5,5)->350; (1,5)->150. Total 800, persoane 10+5+5=20. Corect!
Enunt (foto):