Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- #include "pch.h"
- #include <iostream>
- #include <stdio.h>
- #include <malloc.h>
- #include <stdlib.h>
- int Check_size(int size);
- int input(int (*mas), int size);
- int output(int (*mas), int size);
- int Sum_Min(int (*mas), int size);
- int Last_null(int (*mas), int size);
- int main()
- {
- int size = 0;
- printf("Enter the size of the integer array: ");
- scanf("%d", &size);
- Check_size(size);
- int *mas;
- mas = (int*)malloc(size * sizeof(int));
- input(mas, size);
- printf("Array: ");
- output(mas, size);
- Sum_Min(mas, size);
- Last_null(mas, size);
- free(mas);
- system("pause");
- return 0;
- }
- int Check_size(int size)
- {
- if ((size > 50) || (size < 1))
- {
- printf("\nWrong size of the array.\n");
- printf("Enter the size of the integer array: ");
- scanf("%d", &size);
- }
- return size;
- }
- int input(int (*mas), int size)
- {
- printf("\nEnter the integer array elements:\n");
- for (int i = 0; i < size ; i++)
- {
- printf("a[%d] = ", i);
- scanf("%d", &(*mas));
- mas++;
- }
- return size;
- }
- int output(int (*mas), int size)
- {
- for (int i = 0; i < size ; i++)
- {
- printf("%d ", *mas);
- mas++;
- }
- return size;
- }
- int Sum_Min(int (*mas), int size)
- {
- int sum = 0;
- for (int i = 0; i < size; i++)
- {
- if (*mas < 0)
- {
- *mas = (*mas) * (-1);
- sum = sum + (*mas);
- }
- mas++;
- }
- printf("\nMin sum is %d \n", sum);
- return sum;
- }
- int Last_null(int (*mas), int size)
- {
- int num;
- mas = mas + size - 1;
- for (int i = size - 1; i >= 0; i--)
- {
- if ((*mas) == 0)
- {
- num = i;
- break;
- }
- *mas--;
- }
- printf("\nLast index of null element of the array is %d\n", num);
- return num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement