View Code of Problem 17

#include<stdio.h>
int main()
{
	int m,n,i,j,t1,t2;
	int a[100][100];
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				scanf("%d",&a[i][j]);
			}
		}
		t1=0;
		t2=a[0][0];
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				if(t1<a[i][j])
					t1=a[i][j];
				if(t2>a[i][j])
			 		t2=a[i][j];
			} 
				
		} 
		 printf("%d\n",t1-t2);
	}
	return 0;
 } 

Double click to view unformatted code.


Back to problem 17