Here, in fact, the whole program ...

#include <conio.h> #include <stdio.h> #include <math.h> void vyvod(float*,int,int); //Скорей всего неверно что-то здесь// int vnutri(float,float); float pryamaya(float,float,float,float); void sort(float*,int,int); int main() { int i,j=0,l=0; float k,b,A[15][3],B[15][4],C[15][6],r; clrscr(); printf("Vvedite coefficienty functii y=kx+b\nk="); scanf("%f",&k);//k=10.5// printf("\nb="); scanf("%f",&b);//b=-64// FILE *file1; file1=fopen("POINTS.txt","rt"); for(i=0;i<15;i++) { A[i][0]=i+1; fscanf(file1,"%f,%f;",&A[i][1],&A[i][2]); } //Здесь всё нормально из файла считывается...// printf("Massiv D1\n N xy"); vyvod(&A[0][0],15,3); //А здесь при обращении к функции начинаются проблемы// for(i=0;i<15;i++) { l=vnutri(A[i][1],A[i][2]); if(l==1) { B[j][0]=j+1; B[j][1]=A[i][0]; B[j][2]=A[i][1]; B[j][3]=A[i][2]; j=j+1; } } printf("Massiv D2\n N2 N1 xy"); vyvod(&B[0][0],j,4); //Ну и здесь соответственно тоже аналогично...// l=0; for(i=0;i<j;i++) { r=pryamaya(B[i][2],B[i][3],k,b); if(r<=3.2) { C[l][0]=l+1; C[l][1]=B[i][0]; C[l][2]=B[i][1]; C[l][3]=B[i][2]; C[l][4]=B[i][3]; l++; } } printf("Massiv D3\n N xy"); vyvod(&C[0][0],l,6); sort(&C[0][0],l,6); vyvod(&C[0][0],l,6); getch(); fclose(file1); return(0); } void vyvod(float *A,int a,int b) //Здесь почему-то массив не передаётся ф-ции// { int i,j; FILE *file2; file2=fopen("MASSIVES.txt","at"); for(i=0;i<a;i++) { for(j=0;j<b;j++) { printf("%5.1f",A[i][j]); fprintf(file2,"%5.1f",A[i][j]); } printf("\n"); fprintf(file2,"\n"); } fclose(file2); } int vnutri(float x,float y) { int m=x; float k=0,min,max; switch(m) { case 1:max=10;min=1;break; case 2: case 3: max=9;min=1;break; case 4: case 5: case 6: max=8;min=1;break; case 7: case 8: case 9: max=7;min=1;break; case 10: case 11: case 12: max=6;min=1;break; case 13: max=4;min=1;break; case 14: max=2;min=1;break; case 15: max=0;min=0;break; } if (y>=min && y<=max) k=1; return(k); } float pryamaya(float x,float y,float k,float b) { float r; r=k*xb; y=fabs(yr); x=y/k; r=(x*y)/sqrt(pow(x,2)+pow(y,2)); return(y); } void sort(float *C,int a,int b) { int i,j,t; for(i=0;i<a-1;i++) { if(C[i][b-1]>C[i+1][b-1]) { for(j=0;j<b;j++) { t=C[i][j]; C[i][j]=C[i+1][j]; C[i+1][j]=t;} } } } 
  • Yes, it’s very difficult to figure out your code ... But first, what’s this program to do? At least in brief. - Rams666
  • And yet, the message has a C ++ label, then why do you use input and output methods since cout and cin are simpler, and the program looks clearer!? - Rams666
  • I think it would be useful for the author of the question to get acquainted with the concept of "formatted code" - andrybak
  • Yes, sorry, this is an ordinary SI, mixed up ... In the program, you need to extract the coordinates of points from the file, put them into a two-dimensional array, then display this array, and then change it somewhere and display it again. There's probably a problem with passing this array to a function. - Yerdna

1 answer 1

So you incorrectly transfer a two-dimensional array to a function. It is necessary to transfer so:

 void vyvod(float A[][10], int a, int b) 

where 10 is a constant (written for example), indicating the length of this array dimension.

If you simply pass a pointer, then you should get an element (for example, A [m] [n]) of the array A [y] [x]:

 *(A + x*m + n) 

Probably, there are other errors, but I see this at once.

  • unless the construction A[m][n] does not develop in *(A + x*m + n) ? UPD Because of this, 5[a] is the same as a[5] - andrybak
  • To do this, the compiler must know the base of the array, i.e. x. And if just a pointer is passed, how will he know it? - skegg
  • @mikillskegg understood, thanks - andrybak