Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int a = 5;
  2.         int b = 16;
  3.         if (a != 5 || (a == 5 && b >= 10 && b <= 20)) {
  4.             NSLog(@"1");
  5.         }
  6.         else {
  7.             NSLog(@"0");
  8.         }
  9.         int firstArray[] = {1 , 2 ,3 ,6};
  10.         int firstArrayCount = 4;
  11.         int secondArray[] = {3,4,5,8,10,25};
  12.         int secondArrayCount = 6;
  13.         int newArray[firstArrayCount + secondArrayCount];
  14.         int newArrayCounter = 0;
  15.         int firstIndex = 0;
  16.         int secondIndex = 0;
  17.         while (firstIndex < firstArrayCount && secondIndex < secondArrayCount) {
  18.             if (firstArray[firstIndex] < secondArray[secondIndex]) {
  19.                 newArray[newArrayCounter] = firstArray[firstIndex];
  20.                 firstIndex++;
  21.             }
  22.             else {
  23.                 newArray[newArrayCounter] = secondArray[secondIndex];
  24.                 secondIndex++;
  25.             }
  26.             newArrayCounter++;
  27.         }
  28.        
  29.         while (firstIndex < firstArrayCount) {
  30.             newArray[newArrayCounter] = firstArray[firstIndex];
  31.             newArrayCounter++;
  32.             firstIndex++;
  33.         }
  34.        
  35.         while (secondIndex < secondArrayCount) {
  36.             newArray[newArrayCounter] = secondArray[secondIndex];
  37.             newArrayCounter++;
  38.             secondIndex++;
  39.         }
  40.        
  41.         for (int i = 0; i < secondArrayCount + firstArrayCount; i++) {
  42.             NSLog(@"%d" , newArray[i]);
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement