Home > Back-end >  Daffodil number
Daffodil number

Time:01-16

How did, every brother please ask C only output the number of daffodils before two?

CodePudding user response:

Take the daffodil first, and then to take more than 10, from low to high, before the final set aside two good

CodePudding user response:

Printf (" % d \ \ n b ", a);
Learn about?

CodePudding user response:

Yi? I 2 floor of writing good once upon a time, why is not working now?
Which big misgivings?

CodePudding user response:

reference 1/f, confident boy reply:
and daffodils first, and then to take more than 10, from low to high, before the final set aside two good.

Excuse me, can to the code of daffodils after please , thank you for your bosses

CodePudding user response:

Output a/10 directly by the?

CodePudding user response:

While (m! M=0)//o of digits and cubic and
{
O=m % 10;
M=m/10;
Sum=sum + o * o * o;
}


If (sum==m)//when the cubic and=itself that is output

CodePudding user response:

Reference:
 int main () 
{
Int m, n, sum;
For (int I=100; i<1000; I++) {
M=I;
Sum=0;
While (m) {
N=10 m %;
M/=10;
The sum +=n * n * n.
}
If (sum==I) printf (" I=% d, % d, % d \ n ", I, I/100, I/10 10%);
}

return 0;
}

CodePudding user response:

reference 4 floor weixin_54530767 response:
Quote: reference 1/f, confident boy reply:
and daffodils first, and then to take more than 10, from low to high, before the final set aside two good.

Excuse me, can give the code of daffodils after please , big thanks

You ask first daffodils code send out come on, do some modification on the basis of I am when I am with you

CodePudding user response:

refer to the eighth floor confident boy reply:
Quote: refer to 4th floor weixin_54530767 response:
Quote: reference 1/f, confident boy reply:
and daffodils first, and then to take more than 10, from low to high, before the final set aside two good.

Excuse me, can give the code of daffodils after please , big thanks

You ask first daffodils code send out come on, I am when I am with you do some modification on the basis of

#include
Int main ()
{
The int data, hun, ten digit, count=0;
For (data=https://bbs.csdn.net/topics/100; The data <1000; Data++)
{
Hun=data/100;
Ten=(data - data - hun * 100);
Digit=data % 10;
If (data=https://bbs.csdn.net/topics/=hun * * hun hun digit digit ten ten plus ten * * * * * digit)
Printf (" % d ", data);
}
return 0;
}

Then behind how to count the output 2 daffodil number I won't,

CodePudding user response:

 # include 
Int main ()
{
The int data, hun, ten digit, count=0;
For (data=https://bbs.csdn.net/topics/100; The data <1000; Data++)
{
Hun=data/100;
Ten=data/10% 10;
//ten=(data - data - hun * 100);
Digit=data % 10;
//if (data=https://bbs.csdn.net/topics/=hun * * hun hun digit digit ten ten plus ten * * * * * digit)
If (data=https://bbs.csdn.net/topics/=hun * * hun hun + ten * * ten plus ten digit digit * * digit)
{
count++;
If (count<=2) printf (" % d \ n ", data);
}
}

return 0;
}

CodePudding user response:

 # include & lt; stdio.h> 
#include

Int check_narcissus (int num, char * digit, int len)
{
Int TMP=num;
Int sum=0, I=0;

While (TMP) {
The sum +=pow (TMP % 10, 3);
Digit len] [I %=10 + TMP % '0'.
TMP/=10;
i++;
}
If (sum==num)
return 1;

return 0;
}

Int main ()
{
# if 0
int i;
Char digit [3]={0};

For (I=100; I & lt; 1000000; I++) {
If (check_narcissus (I, digit, 2))
Printf (" % d is refers to the number, % s! \ n ", I, digit);
}

# the else
The int data, hun, ten digit, count=0;

For (data=https://bbs.csdn.net/topics/100; The data <1000; Data++)
{
Hun=data/100% 10;
//ten=(data - data - hun * 100);
Ten=(data/10) % 10;
Digit=data % 10;
//if (data=https://bbs.csdn.net/topics/=hun * * hun hun digit digit ten ten plus ten * * * * * digit)
If (data=https://bbs.csdn.net/topics/=hun * * hun hun + ten * * ten plus ten digit digit * * digit)
Printf (" % d, two bit: % d \ n ", data, data/10);
}

# endif

return 0;
}

For your reference ~

If we know that daffodil number is a three digits, strives for the top two not easily? In addition to the 10 can get directly, also need not I bother,

The host's daffodil number has a problem,
  • Related