Advertisement
lezsakdomi

K. 518

Dec 12th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int limit; cout<<"Limit? "; cin>>limit;
  8.  
  9.     cout<<"\\table{ n & a hatszögszám & a vizsgált eset sorszáma "<<"\\\\\n";
  10.  
  11.     int curr=28, id=4, i=1;
  12.     bool was=false;
  13.     while(curr<=limit){
  14.         cout<<id<<" & "<<curr<<" & "<<i<<"."<<((curr<limit) ? ((was=true), "\\\\") : ((was=false), ""))<<"\n";
  15.  
  16.         id++; i++;
  17.         curr+=4*(id-1)+1;
  18.     }
  19.  
  20.     if (was) {
  21.         cout<<id<<" & "<<curr<<" & "<<i-1<<"+1"<<"\n";
  22.     }
  23.  
  24.     cout<<"}";
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement