/* This program is designed for computing great common divisor of
two positive long integers */
/* Euclidean algorithm */
#include <math.h>;
void main()
{
/*input a & b; */
long int a, b;
long int temp;
long int rm;
printf("lease input a positive long integer:\n"
scanf("%d",&a);
printf("lease input the second long integer:\n"
scanf("%d",&b);
/* compare a & b; */
if(a<b)
{
temp=b;
b=a;
a=temp;
}
rm=gcd(a,b);
printf("The great common divisor of a and b is: %d\n", rm);
}
long int gcd(long int a, long int b)
{
long int r0,r1,r;
long int q;
r0=a;
r1=b;
r=b;
while(r>;0)
{
q=r0/r1;
r=r0-q*r1;
r0=r1;
r1=r;
}
return (r0);
}作者: lenovo 時(shí)間: 2004-02-13 22:59 標(biāo)題: 求教如何處理c程序中的"重定義類型不匹配"的錯(cuò)誤? scanf("%d",&a);
把%d改成%ld,其他的地方也一樣。
還有用long定義就可以了。作者: yejin13 時(shí)間: 2004-02-15 16:36 標(biāo)題: 求教如何處理c程序中的"重定義類型不匹配"的錯(cuò)誤? 你必須在main函數(shù)前聲明gcd這個(gè)函數(shù)!