2021年3月18日星期四

Show only positive numbers in an array

main()  {      int i,j,n,a[10][10],b[10];      printf("Intr. n=");      scanf("%i",&n);      for(i=0;i<n;i++)          for(j=0;j<n;j++)              scanf("%i",&a[i][j]);      for(i=0;i<n;i++) {          printf("\n");          for(j=0;j<n;j++)              printf("%5i",a[i][j]);}      printf("\npozitive b:\n");      for(i = 0; i < n; i ++)      {          if(a[i][j] >= 0)          {              printf("%d  ", b[i]);          }      }      getch();  }  

I have this code right here that creates a table and i wanted to create a separate one only with the positive numbers of the first one

when i enter like the values 3 and 1 2 3 4 5 6 7 8 9 I get random numbers like 8 40 18421

https://stackoverflow.com/questions/66685998/show-only-positive-numbers-in-an-array March 18, 2021 at 02:44PM

没有评论:

发表评论