Advertisement
J3st3rs_j0k3

pr2_5(1)

Oct 12th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 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;
  8.     int sum = 0;
  9.     int n; //количестыо деталей
  10.     printf("Введите кол-во деталей n = ");
  11.     if(scanf("%d", &n) == 1 && scanf("%d %d %d", &t1, &t2, &t3) == 3) {
  12.        
  13.         sum = t1 + t2 + t3;
  14.         printf("sum = %d\n", sum);
  15.        
  16.         int i = 0;
  17.         while (i < n-1){
  18.             if(scanf("%d %d %d", &t1, &t2, &t3) == 3){
  19.            
  20.                 if ((t1<0) || (t2<0) || (t3<0)){
  21.                     printf("Ошибка");
  22.                     break;
  23.                 }
  24.                 else{
  25.                     sum = sum + t1 + t2 + t3;
  26.                     printf("new_sum = %d\n", sum);
  27.                 }
  28.             }
  29.             i++;
  30.         }
  31.             printf("Общее время выработки всех деталей = %d", sum);
  32.     }
  33.     else printf("Ошибка ввода");
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement