Oh sorry for that, I'm new here.
Now I want in each line find the smallest number, I tried with this code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i, j, n, m, k, *min, *rod;
srand(time(NULL));
n=rand()%10+1;
m=rand()%10+1;
printf("lines %d columns %d\n",n,m);
rod=(int*)malloc(n*m*sizeof(int));
k = 0;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
*(rod+k++)=rand()%10+1;
free(rod);
k = 0;
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
printf(" %d",*(rod+k++));
printf("\n");
}
//------------------------------------------//
k=0;
min=rod;
*min=*rod;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
if (*(rod+k++) < *min)
*min = *(rod+k++);
printf("smallest number in the line: %d\n", *min);
}
system("pause");
return 0;
}
but always i get zero's
what should I do?
Thanks for the help