How to combine two numbers in Objective-C

How can I combine two numbers such as 7 and 6 to cast the number 76 or 3 and 3, so the result is 33, in objective-c?

+3
source share
5 answers

There is no inline character to combine numbers. However, you can do this by doing:

int first; /* Assuming this is initialized to the first number */
int second; /* Assuming this is initalized to the second number */
int myVal = [[NSString stringWithFormat:@"%d%d",first, second] intValue];
+15
source

FirstNum * 10 + secondNum: -)

+5
source

x y xy,

10 * x + y.

7 6

7 * 10 + 6 = 76

+1

objective-c, :

  • , nums = array (7,6), result = 0, foreach . : res = res * 10 + . , 7 , . :

    Array nums = Array (7,6,8,9); int res = 0; int value; foreach ( nums) res = res * 10 + ;

  • , , . , , .

,

^

+1

Source: https://habr.com/ru/post/1727128/


All Articles