Answer the question
In order to leave comments, you need to log in
How to get rid of invalid type argument of unary (have) error in C?
I wrote the code, it seems to be correct, but I got errors from which I can’t get rid of even looking at the answers on foreign forums. Pasted the whole code. I write in Atom, I compile via gcc
Here is what the compiler produces:
gcc Kimlaba7.c -o Kimlaba7.exe
/*
Дана матрица В(8,8). Заменить в каждой строке матрицы
максимальный элемент нулем.
*/
#include<stdio.h>
int VVOD(int X){
int i,j;
printf("Vvedite massive:\n");
for(i=0;i<4;i++){
for(j=0;j<4;j++){
scanf("%d",X+i*4+j );
}
}
}
int VIVOD(int X){
int i,j,k=0;
printf("Vivod massiva \n");
for(i=0;i<4;i++){
for(j=0;j<4;j++){
printf("%2d \n",*(X+i*4+j));
k++;
if(k==4){
printf("\n");
k=0;
}
}
}
}
int MAXANDOBMEN(int X){
int i=0,j=0,max=*(X+i*4+j),maxj=0;;
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(max>*(X+i*4+j)){
max=*(X+i*4+j);
maxj=j;
}
}
*(X+i*4+max)=0;
}
}
int main(){
int A[4][4];
VVOD(A);
VIVOD(A);
MAXANDOBMEN(A);
}
/*
Дана матрица В(8,8). Заменить в каждой строке матрицы
максимальный элемент нулем.
*/
#include<stdio.h>
int VVOD(int* X){
int i,j;
printf("Vvedite massive:\n");
for(i=0;i<4;i++){
for(j=0;j<4;j++){
scanf("%d", X+i*4+j );
}
}
}
int VIVOD(int* X){
int i,j,k = 0;
printf("Vivod massiva \n");
for(i=0; i < 4; i++){
for(j=0; j < 4; j++){
printf("%3d", *(X+i*4+j));
k++;
if(k == 4){
printf("\n");
k = 0;
}
}
}
}
int MAXANDOBMEN(int* X){
int i = 0, j = 0, k = 0,max = 0, maxj = 0;
for(i = 0; i < 4; i++){
max = *(X+i*4+j);
for(j = 0; j < 4; j++){
if(max < *(X+i*4+j)){
max = *(X+i*4+j);
maxj = j;
}
}
j=0;
*(X+i*4+maxj) = 0;
}
}
int main(){
int A[4][4];
VVOD(*A);
VIVOD(*A);
MAXANDOBMEN(*A);
VIVOD(*A);
}
Answer the question
In order to leave comments, you need to log in
Read , (Don't be afraid of the C++ in the article's title, the only difference is how it prints to the screen). Now you are doing something strange. You declared the parameters as int, not *int.
PS I recommend immediately abandoning the caps in the names of functions, as it is customary to call constants. Transliteration is also not desirable, use a translator and learn English. After "," a space is placed. Before and before +-= etc. spaces are also customary.
so it is written
*(X+i*4+max)=0;
you can't do that
X+i*4+max is not a pointer
In VVod it's not at all clear what was passed.
You would be defined, with pointers, links or with what you work. Porridge
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question