Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct Loves{
- int lovesszam;
- int talalatszam;
- string sorozat;
- int pontszam;
- };
- int loertek(string sor){
- int aktpont=20;
- int ertek=0;
- int i=0;
- while(i<sor.length()){
- if(aktpont>0 && sor.at(i)=='-'){
- aktpont=aktpont-1;
- }
- else{
- ertek=ertek+aktpont;
- }
- }
- return ertek;
- }
- int main()
- {
- int db;
- fstream f;
- f.open("verseny.txt",ios::in);
- f>>db;
- Loves hit[db];
- int i=0;
- int legn=0;
- int legnhol;
- while(i<db){
- f>>hit[i].sorozat;
- hit[i].lovesszam=hit[i].sorozat.length();
- //3. feladathoz
- if(hit[i].lovesszam>legn){
- legn=hit[i].lovesszam;
- legnhol=i;
- }
- i++;
- }
- f.close();
- cout<<"2.feladat"<<endl;
- i=0;
- while(i<db){
- if(hit[i].sorozat.find("++") == string::npos) cout<< i+1<<" ";
- i++;
- }
- cout<<endl<<endl<<"3.feladat"<<endl;
- //lásd feltöltéskor
- cout<<legnhol+1<<" Versenyzo adta le a legtobb lovest"<<endl;
- i=0;
- while(i<db){
- hit[i].pontszam=loertek(hit[i].sorozat);
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement