0
Separate some numbers
if there is number 123.456. how to get the output : 100.000 20.000 3.000 400 50 6 or if i input 123. the output is: 100 20 3 just some kind like that. what the fnction should i use? array ? but how ?
9 Respostas
+ 1
Get the input as a string
+ 1
char number;
int size, currenNum;
cin >> number;
for(int i=0; i < size=sizeof(number); i++){
cout << number[i];
for(int j=0; j<size-i; j++) cout << '0';
cout << endl;
}
0
ohh so i can get the size of char as int value?
0
i cant compile the code, its error. am i missing some library? but i have known the point.
0
sizeof (number) is yhe size in bytes of the array, a char has 1 byte so every byte is a new char
0
but i got the error: you have to declare
char* number
as a pointer (array)
sorry man
0
tell me the error you get compiling
0
thx man ! awesome