Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. /*Дана последовательность целых чисел {Aj}. Hайти произведение чисел, абсолютная величина котоpых не пpевосходит 10, наибольшее из таких чисел и номеp этого числа в последовательности.*/
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <stdbool.h>
  5. // Shpilevaya Ksenia 4 lab: 25
  6. int main() {
  7.     int n;
  8.     scanf("%d", &n);
  9.     int mas[n];
  10.     int j, number;
  11.     int prnum = 1;
  12.     bool check = false;
  13.     int max = -32768;
  14.     for(j = 1; j <= n; j++)
  15.     {
  16.         scanf("%d", &mas[j]);
  17.         if (abs(mas[j]) <= 10)
  18.         {
  19.             check = true;
  20.             prnum = prnum * mas[j];
  21.             if (mas[j] > max)
  22.             {
  23.                 max = mas[j];
  24.                 number = j;
  25.             }
  26.         }
  27.     }
  28.     if (check == false) printf("No");
  29.     else printf("%d %d %d", prnum, max, number);
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement