+ 2

How can i seperate a long number like int numb= 233 into int a=2 int b= 3 int c=3

5th Feb 2017, 12:26 PM
themilza
themilza - avatar
6 odpowiedzi
+ 4
You should cast to string the given number and convert to integer each character composing the string
5th Feb 2017, 12:32 PM
Michael Isac Girardi
Michael Isac Girardi - avatar
5th Feb 2017, 1:22 PM
Michael Isac Girardi
Michael Isac Girardi - avatar
+ 4
you could store each single integer to an array
5th Feb 2017, 6:36 PM
Michael Isac Girardi
Michael Isac Girardi - avatar
+ 2
if you have to make operations on the results try this: int bigNumber = 321; int a = bigNumber/100; //a is 3 bigNumber-=a*100; //bigNumber is 2(321-300) int b = bigNumber /10; // b is 2 int c= bigNumber-b*10; //c is 1 (21-20)
5th Feb 2017, 2:01 PM
seamiki
seamiki - avatar
+ 2
michael how can i use the variables so i can use them in a formel like 233=int a int b= 2 int c =3 int d =3 b*3 +c*5+d*9=sum
5th Feb 2017, 5:23 PM
themilza
themilza - avatar
+ 1
can you pls give me a exemple
5th Feb 2017, 12:56 PM
themilza
themilza - avatar