Advertisement
boky8

Apsolutna vrijednost

Feb 27th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. int apsolutna(int broj) {
  2.     if (broj < 0)
  3.         return -broj;
  4.  
  5.     return broj;
  6. }
  7.  
  8. int main() {
  9.     int brojevi[5];
  10.    
  11.     cout << "Unesi brojeve -------------" << endl;
  12.     for (int i = 0; i < 5; i++) {
  13.         cout << "Unesi " << i+1 << ". broj: ";
  14.         cin >> brojevi[i];
  15.     }
  16.  
  17.     cout << endl;
  18.     cout << "Apsolutne vrijednosti -----" << endl;
  19.     for (int i = 0; i < 5; i++) {
  20.         cout << "|" << brojevi[i] << "| = " << apsolutna(brojevi[i]) << endl;
  21.     }
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement