+ 1

Write a program that reads an integer consisting of three numbers and then prints the number of the digits, the number of tens,

30th Mar 2017, 8:01 PM
muhanad
muhanad - avatar
5 Respostas
+ 11
In C++: int x = 0; cin >> x; cout << x/100 << endl; //hundreds cout << (x/10)%10 << endl; //tens cout << x%10 << endl; //units
30th Mar 2017, 8:10 PM
Jafca
Jafca - avatar
+ 9
Which language?
30th Mar 2017, 8:02 PM
Tashi N
Tashi N - avatar
+ 2
thanks so much
30th Mar 2017, 8:12 PM
muhanad
muhanad - avatar
+ 2
#include <math.h> #include <iostream> int findSize(int num) { sum = 0; while(num/=10) { sum+=1; } return sum; } int main() { int x = 0; cin >> x; int size = findSize(x); for(auto i = size-1; i>=0; i++) { cout << (x/pow(10, i))%10; } } or something like that, but that's the idea. and you can try to optimize this of course.
30th Mar 2017, 8:20 PM
anon
anon - avatar
+ 1
in c++ language
30th Mar 2017, 8:32 PM
muhanad
muhanad - avatar