#6503: 可否幫忙看哪裡出錯了呢?


ben11855 (123)


#include <iostream>
#include <math.h>
using namespace std;

int main()
{for(int i=1;i<10;i++)
{for(int j=0;j<10;j++)
{for(int k=0;k<10;k++)
if ((i*100+j*10+k)==i*i*i+j*j*j+k*k*k)
{cout << i*100+j*10+k << "\t";
cout << "\n";}}}
system("pause");
return 0;
}

 

感謝指教@@

#6631: Re:可否幫忙看哪裡出錯了呢?


johnchiang8324 (建中資訊百一級猩猩)


#include
#include
using namespace std;

int main()
{for(int i=1;i<10;i++)
{for(int j=0;j<10;j++)
{for(int k=0;k<10;k++)
if ((i*100+j*10+k)==i*i*i+j*j*j+k*k*k)
{cout << i*100+j*10+k << "\t";
cout << "\n";}}}
system("pause");
return 0;
}

 

感謝指教@@

你的CODE只有判斷到三位數

還有輸出的時候用空格隔開

反正要看完題目