0
I’m starting to study pointer and decided to change my codes to use pointers, only I tried to send this solution to Uri and it gave a message - In Queue -,I don’t know where the bug is,.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int i;
int *vetor(int v[]);
int main(int argc, char** argv)
{
int vet[10],*ponte;
for(i=0;i<10;i++)
{
scanf("%d",&vet[i]);
}
ponte=vetor(vet);
for(i=0;i<10;i++)
{
printf("X[%d] = %d\n",i,ponte[i]);
}
free(ponte);
return 0;
}
int *vetor(int v[])
{
int *igual=(int*)malloc(sizeof(int)*10);
for(i=0;i<10;i++)
{
if(v[i]<=0)
{
igual[i]=1;
}
else
{
igual[i]=v[i];
}
}
return igual;
}
The problem asks for what? That you return the same vector, except that non-positive numbers are exchanged for 1?
– Jefferson Quesado