1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <stdio.h>
int main () {
int A[8][10];
int i,j,m,n,c,d,br=0;
int z;
printf ("m= ");
scanf ("%d",&m);
if (m>7) {printf ("\n \n" "This program accepts maxmimum 7 and minimum 1 rows. Try again."); return 0;}
printf ("\n" "n= ");
scanf ("%d",&n);
if (n>9) {printf ("\n \n" "This program accepts maximum 9 and minimum 1 columns. Try again."); return 0;}
printf ("\n \n");
for (i=0;i<m;i++)
for (j=0;j<n;j++) {
printf ("A[%d][%d]= ",i,j);
scanf ("%d",&A[i][j]);}
printf ("\n \n" "c= ");
scanf ("%d",&c);
printf ("\n" "d= ");
scanf ("%d",&d);
printf ("\n \n" "Matrix elements within the interval [%d,%d]: ",c,d);
for (i=0;i<=m;i++)
for (j=0;j<=n;j++) {
if (A[i][j]>=c && A[i][j]<=d && A[i][j]!=0) {
br++;
printf ("%d ",A[i][j]);}}
printf ("\n \n" "There are %d elements in the matrix that belong to the interval [%d,%d]",br,c,d);
return 0;
} // end
|