Код: Выделить всё
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
float *mem(char a, int kol)
{
int k;
float *mas=NULL;
if ((mas=(float*) malloc(kol*sizeof(float)))==NULL)
printf("Not Memory %c\n",a);
else
{
printf ("massiv %c\n",a);
for (k=0;k<kol;k++)
{
printf("%c[%d]=",a,k); scanf("%f",mas+k);
}
}
return mas;
}
float pros(float *mas,int k)
{
int c; float prois;
prois=1;
for (c=0;c<k;c+=2)
{
if (*(mas+c)!=0) prois*=*(mas+c);
}
printf("prois=%5.2f\n",prois);
return prois;
}
void koll(float *mas,int k)
{
int c, kol=0;
for (c=0;c<k;c++)
{
if(*(mas+c)<0)
{
*(mas+c)=c;
kol++;
}
}
printf("kol=%d\n",kol);
printf("\n");
}
float *mem(char a, int kol);
void koll(float *mas,int k);
void main()
{
int N,M,L;
float *X=NULL,*Y=NULL,*C=NULL;
clrscr();
printf("N,M,L:\n");
scanf("%d,%d,%d",&N,&M,&L);
if ((X=mem('X',N))!=NULL)
{
pros(X,N);
koll(X,N);
getch();
free(X);
}
if ((Y=mem('Y',M))!=NULL)
{
pros(Y,M);
koll(Y,M);
getch();
free(Y);
}
if ((C=mem('C',L))!=NULL)
{
pros(C,L);
koll(Y,M);
getch();
free(C);
}
}