Blue Bridge Cup - Basic Training 06-- special digital

Special numbers:

Problem Description
  153 is a very special number, which is equal to that of cubic and each digit, i.e., 153 = 1 . 1 1 + 5 . 5 5 + 3 . 3 3 All three decimal demand programming to meet this condition.
  
Output format
  output three decimal number satisfying the condition in ascending order of each number per line.

code show as below:

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int n,i,j,k;
	
	for(n=2; n<1000; n++){
		i = (n/100);
		j = (n-i*100)/10;
		k = (n-i*100-j*10);
		if(n==(i*i*i + j*j*j + k*k*k)){
			printf("%d\n",n);
		}	
		
	} 
	return 0;
}

Special number, there is a very nice name: Number of daffodils.

Wonderful it - want to know more, and quickly learn it!

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/88764819