Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int t[12];
  9.     fstream f;
  10.     f.open("in.txt",ios::in);
  11.     int i=0;
  12.     while(i<12){
  13.         f>>t[i];
  14.         i++;
  15.     }
  16.     f.close();
  17.     int osszeg=0;
  18.     int poz;
  19.     i=2;
  20.     while(i<12){
  21.         if(t[i]+t[i-1]+t[i-2]>osszeg){
  22.             osszeg=t[i]+t[i-1]+t[i-2];
  23.             poz=i;
  24.         }
  25.         i++;
  26.     }
  27.     cout<<"A legnagyobb reszosszeg: "<<osszeg<<endl;
  28.     cout<<"Az alabbi honapokban: "<< poz-1 <<". "<< poz <<". "<< poz+1 <<". "<<endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement