最大公约数

来源:互联网 发布:网络信息安全协议书 编辑:程序博客网 时间:2024/05/22 11:44
#include<stdio.h>int fun(int a,int b){  int r;  while((r=b%a)!=0)  {    b=a;    a=r;  }  return a;}int main(){  int n,max,min,temp,count=0;  while(scanf("%d",&n)!=EOF)  {    while(n--)    {      scanf("%d",&temp);      if(count++==0){max=temp;min=temp;}      if(temp<min)min=temp;      if(temp>max)max=temp;    }    printf("%d %d %d",min,max,fun(min,max));  }  return 0;}

0 0