Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. struct Loves{
  8.  int lovesszam;
  9.  int talalatszam;
  10.  string sorozat;
  11.  int pontszam;
  12.  
  13.  
  14. };
  15.  
  16.  
  17. int loertek(string sor){
  18.     int aktpont=20;
  19.     int ertek=0;
  20.     int i=0;
  21.     while(i<sor.length()){
  22.         if(aktpont>0 && sor.at(i)=='-'){
  23.             aktpont=aktpont-1;
  24.         }
  25.         else{
  26.             ertek=ertek+aktpont;
  27.         }
  28.     }
  29.    
  30.     return ertek;
  31.  
  32. }
  33.  
  34.  
  35. int main()
  36. {
  37.     int db;
  38.     fstream f;
  39.     f.open("verseny.txt",ios::in);
  40.     f>>db;
  41.    
  42.     Loves hit[db];
  43.     int i=0;
  44.     int legn=0;
  45.     int legnhol;
  46.     while(i<db){
  47.         f>>hit[i].sorozat;
  48.         hit[i].lovesszam=hit[i].sorozat.length();
  49.         //3. feladathoz
  50.         if(hit[i].lovesszam>legn){
  51.             legn=hit[i].lovesszam;
  52.             legnhol=i;
  53.         }
  54.         i++;
  55.     }
  56.     f.close();
  57.     cout<<"2.feladat"<<endl;
  58.     i=0;
  59.     while(i<db){
  60.        if(hit[i].sorozat.find("++") == string::npos) cout<< i+1<<" ";
  61.         i++;
  62.     }
  63.     cout<<endl<<endl<<"3.feladat"<<endl;
  64.     //lásd feltöltéskor
  65.     cout<<legnhol+1<<" Versenyzo adta le a legtobb lovest"<<endl;
  66.  
  67.     i=0;
  68.     while(i<db){
  69.        hit[i].pontszam=loertek(hit[i].sorozat);
  70.         i++;
  71.     }
  72.  
  73.  
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement