Advertisement
J3st3rs_j0k3

pr2_5

Oct 12th, 2021 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. int main()
  6. {
  7.     int t1, t2, t3, x, y, z;
  8.     int n; //количестыо деталей
  9.     if(scanf("%d", &n) == 1 && scanf("%d %d %d", &t1, &t2, &t3) == 3) {
  10.         x = t1; //время обработки на 1 станке
  11.         y = x + t2; //время обработки на 1 и 2 станках
  12.         z = y + t3; //время обработки на всех станках
  13.        
  14.         printf("t1 = %d\n", t1);
  15.         printf("t2 = %d\n", t2);
  16.         printf("t3 = %d\n", t3);
  17.        
  18.         printf("x = %d\n", x);
  19.         printf("y = %d\n", y);
  20.         printf("z = %d\n", z);
  21.        
  22.         int i = 0;
  23.         while (i < n-1){
  24.             scanf("%d %d %d", &t1, &t2, &t3);
  25.            
  26.             printf("t1 = %d\n", t1);
  27.             printf("t2 = %d\n", t2);
  28.             printf("t3 = %d\n", t3);
  29.            
  30.             if ((t1<0) || (t2<0) || (t3<0)){
  31.                 printf("Ошибка");
  32.                 break;
  33.             }
  34.             else{
  35.                 x += t1;
  36.                 printf("x = %d\n", x);
  37.                 y = (y = x > y? x: y) + t2;
  38.                 printf("y = %d\n", y);
  39.                 z = (z = y > z? y: z) + t3;
  40.                 printf("z = %d\n", z);
  41.             }
  42.             i++;
  43.         }
  44.             printf("Общее время выработки всех деталей = %d", z);
  45.     }
  46.     else printf("Ошибка ввода");
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement