ret_0

#14

Nov 8th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. main()
  4. {
  5.     int n, i = 0;
  6.     cout << "Enter n (size of arrays): ";
  7.     cin >> n;
  8.     cout << "Enter array a[" << n << "]:\n";
  9.     /* for MVS Compiler
  10.     int* a = new int [n];
  11.     int* b = new int [n]; */
  12.     int a[n], b[n];
  13.     for(; i < n; i++)
  14.         cout << " - a[" << i + 1 << "] = ",
  15.         cin >> a[i];
  16.     cout << "\nEnter array b[" << n << "]:\n";
  17.     for(i = 0; i < n; i++)
  18.         cout << " - b[" << i + 1 << "] = ",
  19.         cin >> b[i];
  20.     cout << "\nNow we'll count difference:\n";
  21.     for(i = 0; i < n; i++)
  22.         cout << " - Step " << i + 1 << ", difference: " << abs(a[i] - b[i]) << "\n";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment