Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cstdlib>
  3.  
  4. int main(){
  5.     int arr[20];
  6.     for (int i = 0; i < 20; ++i)
  7.     {
  8.            arr[i] = rand() % 100 - 50;  // В диапазоне от -50 до +50
  9.         //   Если старуха попросит с клавиатуры
  10.         //   Тогда поставь  //   на строке 9 и убери со строки 11
  11.         //   scanf("%i", &arr[i]);
  12.     }
  13.     bool is_first_positive = false; // Переменная, которая нужна для вывода первого положительного
  14.     for (int i = 0; i < 20; ++i)
  15.     {
  16.         if (arr[i] > 0 && !is_first_positive && arr[i] % 2 == 0)
  17.         {
  18.             is_first_positive = true;
  19.             printf("\nFirst multiple to 2 positive number:  %i\n", arr[i]);
  20.             continue;
  21.             // Тут мы красим его в красный
  22.             // Покрась в цвет сам, я хз как
  23.         }
  24.         printf("%i ", arr[i]);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement