Manchester


私信TA

用户名:wenyajie

访问量:310719

签 名:

在历史前进的逻辑中前进,这个逻辑就是人心向背的逻辑

等  级
排  名 1
经  验 62412
参赛次数 1
文章发表 188
年  龄 0
在职情况 学生
学  校 Xiamen University
专  业 计算机科学

  自我简介:

在历史前进的逻辑中前进,这个逻辑就是人心向背的逻辑

解题思路:
此代码在水仙花数问题1里面有描述,具体过程就不解释了;

注意事项:

参考代码:

思路1:

#include <stdio.h>
#include <math.h>
void panduan( int N );


int main()
{
    for ( int i = 100; i <= 999; i++ )
    {
        panduan( i );
    }
    return(0);
}


void panduan( int N )
{
    int sum = 0, N1 = N;

    while ( N != 0 )
    {
        sum    = sum + pow( (N % 10), 3 );
        N    /= 10;
    }
    if ( sum == N1 )
        printf( "%d\n", sum );
    return;
}

思路2:(c++)

#include<iostream>
using namespace std;

int main()
{
cout<<153<<endl;
cout<<370<<endl;
cout<<371<<endl;
cout<<407<<endl;
return 0;
}


 

0.0分

0 人评分

  评论区