Witam, proszę o pomoc w zadaniu w c++, problem mój dotyczy deklaracji int ocena1; int ocena2; int ocena3. Wiem, że w kodzie mam błąd, nie powinien wszędzie dawać intów, problem polega na tym że nie wiem jak napisać kod, żeby w programie odczytywały mi się oceny zmiennych, które już wpisałem wcześniej i na podstawie tych ocen obliczyła mi się suma oraz średnica. Ja zadeklarowałem do każdego te same nowe zmienne, że tylko odpalić program. Liczę na waszą pomoc! :D
#include <iostream>
using namespace std;
struct student {
string imie;
string nazwisko;
int ocena1;
int ocena2;
int ocena3;};
student wczytaj();
void wyswietl(student s);
float srednia(student s);
bool czyPozytywne (student s);
int main()
{
student wynik;
wynik=wczytaj();
wyswietl(wynik);
return 0;
}
student wczytaj()
{
int ocena1;
int ocena2;
int ocena3;
int suma=0;
student s;
cout<<"Podaj imie studenta: \n "; cin>>s.imie;
cout<<"Podaj nazwisko studenta: \n"; cin>>s.nazwisko;
{
cout<<"Podaj ocene 1: "; cin>>ocena1;
cout<<"Podaj ocene 2: "; cin>>ocena2;
cout<<"Podaj ocene 3: "; cin>>ocena3;
}
for(int licznik=ocena1;licznik=ocena2;licznik++)
suma+=licznik;
cout<<"Suma liczb to "<<suma<<"\n";
return s;
}
float srednia (student s)
{
float suma=0;
float srednia=0;
for (int i=0; i<3; i++)
srednia=suma/3;
return srednia;
}
bool OcenyPozytywne(student s)
{int ocena1;
int ocena2;
int ocena3;
if (ocena1,ocena2,ocena3>=3)
{return true;}
else
{
return false;
}
}
void wyswietl(student s)
{
cout<<"Imie: \n"<<s.imie<<endl;
cout<<"Nazwisko: \n"<<s.nazwisko<<endl;
for (int i=0; i<3; i++)
{int ocena1;
int ocena2;
int ocena3;
cout<<"Ocena \n 1: "<<ocena1<<endl;
cout<<"Ocena \n 2: "<<ocena2<<endl;
cout<<"Ocena \n 3: "<<ocena3<<endl;
}
cout<<"Srednia ocen wynosi: \n"<<srednia(s)<<endl;