ronith
10/31/2018 - 4:11 AM

Round the given number to nearest multiple of 10

//https://www.geeksforgeeks.org/round-the-given-number-to-nearest-multiple-of-10/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    cin>>ws;
    while (t-->0) {
        string s;
        getline(cin, s);
        int n= s.length();
        int num= s[n-1]- '0';
        if (num<=5){
            s[n-1]= '0';
            cout<< s<< endl;
        }
        else {
            s[n-1]= '0';
            int i= n-2;
    
            int carry= 1;
            while (i>=0) {
                if (s[i]== '9') {
                    s[i]= '0';
                }
                else {
                    s[i]+= 1;
                    break;
                }
                i--;
            }
            if (i== -1)
                cout<< 1<< s<< endl;
            else
                cout<< s<< endl;
    
        }
    }
    return 0;
}