#1232: __求助


phenix (phenix)


以下是我的程式碼

#include<stdio.h>
int main ()
{
 long int a,b=1,r;
 
 while(b!=0)
 {          
scanf("%d %d",&a,&b);
  r=a%b;
  a=b;
  b=r;
 }
 printf("%d",a);
}

只要輸入12和5,他就不會輸出

#1235: Re:求助


morris1028 (碼畜)


以下是我的程式碼

#include
int main ()
{
 long int a,b=1,r; 
 scanf("%d %d",&a,&b);  /*寫程式時 要注意位置與順序*/

 while(b!=0)
 {           
  r=a%b;
  a=b;
  b=r;
 }
 printf("%d",a);
}

只要輸入12和5,他就不會輸出


#1285: Re:求助


phenix (phenix)


以下是我的程式碼

#include
int main ()
{
 long int a,b=1,r; 
 scanf("%d %d",&a,&b);  /*寫程式時 要注意位置與順序*/

 while(b!=0)
 {           
  r=a%b;
  a=b;
  b=r;
 }
 printf("%d",a);
}

只要輸入12和5,他就不會輸出

這樣得到的回覆是

編譯錯誤, 請檢查語法是否符合系統所支援的編譯器的要求。
錯誤訊息:
/tmp/code_129631.cpp:1:9: #include expects "FILENAME" or <FILENAME>
/tmp/code_129631.cpp: In function `int main()':
/tmp/code_129631.cpp:5: error: `scanf' undeclared (first use this function)
/tmp/code_129631.cpp:5: error: (Each undeclared identifier is reported only
   once for each function it appears in.)
/tmp/code_129631.cpp:12: error: `printf' undeclared (first use this function)

一開始我就那樣寫,但無法重複執行,只好修改在迴圈內,但就會無法映出

#1292: Re:求助


morris1028 (碼畜)


以下是我的程式碼

#include
int main ()
{
 long int a,b=1,r; 
 scanf("%d %d",&a,&b);  /*寫程式時 要注意位置與順序*/

 while(b!=0)
 {           
  r=a%b;
  a=b;
  b=r;
 }
 printf("%d",a);
}

只要輸入12和5,他就不會輸出

這樣得到的回覆是

編譯錯誤, 請檢查語法是否符合系統所支援的編譯器的要求。
錯誤訊息:
/tmp/code_129631.cpp:1:9: #include expects "FILENAME" or
/tmp/code_129631.cpp: In function `int main()':
/tmp/code_129631.cpp:5: error: `scanf' undeclared (first use this function)
/tmp/code_129631.cpp:5: error: (Each undeclared identifier is reported only
   once for each function it appears in.)
/tmp/code_129631.cpp:12: error: `printf' undeclared (first use this function)

一開始我就那樣寫,但無法重複執行,只好修改在迴圈內,但就會無法映出

抱歉忘記交你,修改成,應該是這樣吧?!

int main ()
{
 long int a,b=1,r; 
 while(scanf("%d %d",&a,&b)==2)  
  {
     while(b!=0)
    {           
     r=a%b;
     a=b;
     b=r;
    }
    printf("%d",a);
  }
 return 0; 
}

#1293: Re:求助


morris1028 (碼畜)


加上換行(\n)就AC了

#1306: Re:求助


chenaren ((′‧ω‧‵))


加上換行(\n)就AC了

 

 

 對啊