Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- void print_array(double *array, int power_of_the_massive){
- for(int i = 0; i < power_of_the_massive; i++){
- printf("%lf ", array[i]);
- }
- }
- int create_array(double *a, int power_of_the_massive){
- a = (double *) calloc(sizeof(double), power_of_the_massive);
- for (int i = 0; i<power_of_the_massive; i++)
- {
- printf("a[%d] = ", i);
- scanf("%lf", &a[i]);
- }
- return 0;
- }
- double find_first_min(int *a, int power_of_the_massive,int index2, double first_min){
- for (int i = 0; i < power_of_the_massive; i++) {
- if (a[i] < first_min) {
- first_min = a[i];
- index2 = i;
- }
- }
- return 0;
- }
- int main(void) {
- int index1 = 0, index2 = 0, power_of_the_massive;
- double *a, *b = NULL;
- printf("power_of_the_massive = ");
- if (scanf("%d", &power_of_the_massive) == 0 || getchar() != '\n') {
- printf("power_of_the_massive is bad");
- return 0;
- }
- if(power_of_the_massive<=0){
- printf("power_of_the_massive is bad");
- return 0;
- }
- a = (double *) create_array(a, power_of_the_massive);
- double first_min=a[0];
- print_array(a, power_of_the_massive);
- for (int i = 0; i < power_of_the_massive; i++) {
- if (a[i] < first_min) {
- first_min = a[i];
- index1 = i;
- }
- }
- for (int i = 0; i < power_of_the_massive; i++){
- if (a[i]==0){
- index2=i;
- }
- }
- b = (double *) calloc(sizeof(double), power_of_the_massive-(index1-index2));
- for (int i=0; i<power_of_the_massive-(index1-index2); i++){
- for(int j=0; i<power_of_the_massive-(index1-index2);j++){
- b[i]=a[j];
- }
- }
- print_array(b, power_of_the_massive-(index1-index2));
- free(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement