Advertisement
jasonpogi1669

Replace last digit of n using C++

Feb 8th, 2022
1,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     for (int d = (n < 10 ? 1 : 0); d < 10; d++) {
  9.         int new_n = n - n % 10 + d;
  10.         cout << new_n << '\n';
  11.     }
  12.     return 0;
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement