Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- int main()
- {
- int t1, t2, t3;
- int sum = 0;
- int n; //количестыо деталей
- printf("Введите кол-во деталей n = ");
- if(scanf("%d", &n) == 1 && scanf("%d %d %d", &t1, &t2, &t3) == 3) {
- sum = t1 + t2 + t3;
- printf("sum = %d\n", sum);
- int i = 0;
- while (i < n-1){
- if(scanf("%d %d %d", &t1, &t2, &t3) == 3){
- if ((t1<0) || (t2<0) || (t3<0)){
- printf("Ошибка");
- break;
- }
- else{
- sum = sum + t1 + t2 + t3;
- printf("new_sum = %d\n", sum);
- }
- }
- i++;
- }
- printf("Общее время выработки всех деталей = %d", sum);
- }
- else printf("Ошибка ввода");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement