Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <set>
- using namespace std;
- typedef struct adatok{
- int ora;
- int perc;
- int tszam;
- string szoveg;
- }ADAT;
- int main()
- {
- int db;
- int i;
- string seged;
- int maxhossz=0;
- int maxhely;
- int minhossz=101;
- int minhely;
- int egyhusz=0;
- int husznegyven=0;
- int kozhossz=0; ///41-60ig hosszú smsek darabszáma
- int hatvannyocvan=0;
- int nyocvanszaz=0;
- fstream f;
- f.open("sms.txt", ios::in);
- f>>db;
- ADAT t[db+1];
- for(int i=0; i<db; i++){
- f>>t[i].ora;
- f>>t[i].perc;
- f>>t[i].tszam;
- getline(f,t[i].szoveg); ///ez a törőkaraktert olvassa be, a telefonszám után
- getline(f,t[i].szoveg);
- if(t[i].szoveg.length()<=20) egyhusz++;
- if(21<=t[i].szoveg.length() && t[i].szoveg.length()<=40) husznegyven++;
- if(41<=t[i].szoveg.length() && t[i].szoveg.length()<=60) kozhossz++;
- if(61<=t[i].szoveg.length() && t[i].szoveg.length()<=80) hatvannyocvan++;
- if(81<=t[i].szoveg.length()) nyocvanszaz++;
- if(t[i].szoveg.length() < minhossz){
- minhossz=t[i].szoveg.length();
- minhely=i;
- }
- if(maxhossz<t[i].szoveg.length()){
- maxhossz=t[i].szoveg.length();
- maxhely=i;
- }
- //cout<<t[i].szoveg<<endl;
- }
- f.close();
- //2.feladat
- cout<<"2. feladat"<<endl;
- if(db<10) cout<<t[db-1].szoveg<<endl;
- else cout<<t[9].szoveg<<endl;
- //3.feladat
- cout<<"3. feladat"<<endl;
- cout<<t[maxhely].ora<<" "<<t[maxhely].perc<<" "<<t[maxhely].tszam<<" "<<t[maxhely].szoveg<<endl;
- cout<<t[minhely].ora<<" "<<t[minhely].perc<<" "<<t[minhely].tszam<<" "<<t[minhely].szoveg<<endl;
- //4.feladat
- cout<<"4.feladat"<<endl;
- cout<<"0-20 "<<egyhusz<<endl;
- cout<<"21-40 "<<husznegyven<<endl;
- cout<<"41-60 "<<kozhossz<<endl;
- cout<<"61-80 "<<hatvannyocvan<<endl;
- cout<<"81-100 "<< nyocvanszaz<<endl;
- //5.feladat
- cout<<"5.feladat"<<endl;
- int aktordb=1;
- int extradb=0;
- for(i=1; i<db; i++){
- if(t[i].ora==t[i-1].ora){
- aktordb++;
- }else {
- if(aktordb>10) extradb=extradb+aktordb-10;
- aktordb=1;
- }
- }
- cout<<extradb<<"-szor kell felhívnia a szolgáltatót"<<endl;
- //6.feladat
- cout<<"6.feladat"<<endl;
- int maxido=0;
- int utolso_ido=0;
- for(i=0; i<db; i++){
- if(t[i].tszam==123456789 && utolso_ido==0) {
- utolso_ido= t[i].ora*60+t[i].perc;
- }
- if(t[i].tszam==123456789 && utolso_ido !=0){
- if(maxido<t[i].ora*60+t[i].perc-utolso_ido){
- maxido=t[i].ora*60+t[i].perc-utolso_ido;
- utolso_ido=t[i].ora*60+t[i].perc;
- //cout<<maxido<<endl;
- }
- }
- }
- if(maxido==0) cout<<"Nem volt elég sms"<<endl;
- else cout<<"Leghosszabb eltelt idő: "<<maxido/60<<" óra "<< maxido%60<<" perc"<<endl;
- //7.feladat
- cout<<"7.feladat"<<endl;
- cin>>t[db].ora;
- cin>>t[db].perc;
- cin>>t[db].tszam;
- getline(cin,seged); ///elozo int utani /n
- getline(cin,t[db].szoveg);
- //cout<<t[db].szoveg<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement