Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int Pozitivna ( int X )
- {
- if ( X >= 0 )
- {
- return X ;
- }
- else
- {
- int Y = X - (2*X) ;
- return Y ;
- }
- }
- int main()
- {
- printf("Unesite broj kolone: " ) ; int Kolona ; scanf("%d" , &Kolona ) ;
- printf("Unesite broj elemenata iz te kolone koje treba sabrati: " ) ; int X ; scanf("%d" , &X ) ;
- int PlusKolona = Pozitivna ( Kolona ) ;
- int PrviBroj ;
- int PrviInkrement = (PlusKolona+1)*2 ;
- int DrugiInkrement = PrviInkrement ;
- int Zbir ;
- int k1 = 1 ;
- while ( k1 < X )
- {
- k1++;
- PrviInkrement = PrviInkrement + 2 ;
- DrugiInkrement = DrugiInkrement + PrviInkrement ;
- }
- if ( PlusKolona == Kolona )
- {
- PrviBroj = (Kolona+1)*(Kolona+1) ;
- }
- else
- {
- PrviBroj = Kolona*Kolona+1 ;
- }
- if ( X == 1 )
- {
- printf("Zbir je %d" , PrviBroj ) ;
- }
- else
- {
- Zbir = PrviBroj * X + DrugiInkrement ;
- Zbir = Zbir - 4 ;
- printf("Zbir je: %d" , Zbir ) ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement