problem solving

0 Mahmoud Abdel Ghani · February 28, 2015
suppose you have two integer numbers N,X ,And (0=<N<=103),(1=<X<=99),If the last two digits of the input number N are less than input  X, the number is rounded down for the the next greater hundred., otherwise the number is rounded up to  the next smaller hundred........i just want to know to determine the last two digit of number N...is there already a function do that in c++ or something like that?

Post a Reply

Replies

Oldest  Newest  Rating
0 Mahmoud Abdel Ghani · March 1, 2015
thanks for your answer

this is the problem:
/images/forum/upload/2015-03-01/da4f3b69e8788c6aa4fffe1198796d5d.PNG
and this is my solution: if you know better solution tell me

#include<iostream>

using namespace std;

int main(){
int T, N, X,Result;
cin >> T;
if (T >= 1 && T <= 1000)
{
for (int i = 0; i < T; i++)
{
cin >> N >> X;
if (X>(N % 100))
{
Result= N - (N % 100);

}
else
{
Result = (N - (N % 100)) + 100;
}
cout << Result << endl;
}
}


return 0;
}
0 Mahmoud Abdel Ghani · March 1, 2015
I found a function called round in library math.h
0 Bernard Pyc0d333 Parah · March 1, 2015
yea, you might also want to check out ceil,floor, trunc, rint and nearbyint functions under it too.
  • 1

C++

107,324 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator