Created
December 1, 2012 15:41
-
-
Save ajuanhuang/4182935 to your computer and use it in GitHub Desktop.
数字差距的绝对值
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int n,m,c,i,min,j,k=0,a[1000],b[1000]; | |
scanf("%d%d",&n,&m); | |
for(i=0;i<n;i++) | |
scanf("%d",&a[i]); | |
for(j=0;j<m;j++) | |
scanf("%d",&b[j]); | |
min=b[0]-a[0]; | |
if(min<0) | |
min=-min; | |
for(i=0;i<n;i++) | |
for(j=0;j<m;j++) | |
{ | |
c=a[i]-b[j]; | |
if(c<0) | |
c=0-c; | |
if(min>c) | |
min=c; | |
} | |
printf("%d\n",min); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment