Answer the question
In order to leave comments, you need to log in
How to remake to: input of initial arrays; output of initial arrays; processing arrays; in the output of the result were through functions?
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL, "");
int A[5], B[6], C[11];
int* d, * w, * e;
int i, j,tmp;
int k = 0;
d = A;
w = B;
e = C;
srand(time(NULL));
for (i = 0; i < 4; i++)
{
*(d + i) = 10 + rand() % 90;
*(C + k++) = *(d+i);
}
for (i = 0; i < 6; i++)
{
*(w+i) = 10 + rand() % 90;
*(C+k++) = *(w + i);
}
for (i = 0; i < 10 - 1; i++)
{
for (j = 0; j < 10 - i - 1; j++)
{
if (*(e+j) > *(e+j + 1))
{
int tmp = *(e+j);
*(e + j) = *(e+j + 1);
*(e + j + 1) = tmp;
}
}
}
for (i = 0; i < 10; i++)
{
printf("Элемент массива %d \n", *(e + i));
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
void vvodA(int* A, int* C)
{
for (int i = 0; i <= 4; i++)
{
A[i] = 10+ rand() % 90 ;
C[i] = A[i];
}
}
void vvodB(int* B, int* C)
{
for (int i = 5; i <= 10; i++)
{
B[i - 5] = 10+ rand() % 90;
C[i] = B[i - 5];
}
}
void sort(int* C)
{
for (int i = 10, j = 0; i >= 0; j--)
{
int end = 1, min = 0;
for (j = 0; j < i; j++)
{
if (C[j] > C[j + 1])
{
min = C[j];
C[j] = C[j + 1];
C[j + 1] = min;
end=0;
}
}
if (end == 1)
break;
}
}
void print(int* C)
{
for (int i = 0; i <= 10; i++)
{
printf("Array element %d: %d \n", i + 1, C[i]);
}
}
int main()
{
setlocale(LC_ALL, "");
int A[5], B[6], C[11];
srand(time(NULL));
vvodA(A, C);
vvodB(B, C);
sort(C);
print(C);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question