#include <stdio.h>#include<stdbool.h>//number of daffodils--everybody cubic and equal to itselfvoidsxh () {intx, Y, Z printf ("find the three-digit number of daffodils \ n"); for(intI= -; i<=999; i++) {x= i/ -; Y= i% -/Ten; Z= i% -%Ten; if(i = = x*x*x + y*y*y + z*z*z) printf ("%d,", i); } printf ("\ n");}//determine if a number is primevoidIspri () {intx; BOOLIsP =true; printf ("Enter a number to determine if it is prime!\n"); scanf ("%d",&x); for(intI=1; i<x; i++) { if(x%i = =0&& I! =1) IsP=false; } if(IsP) printf ("%d is prime number \ n", x); Elseprintf ("%d is not a prime number \ n", x);}//Outputall prime numbers between N and MvoidIspris () {intN,m,i; BOOLIsP =true; printf ("enter two numbers and output all prime numbers between two numbers!\n"); scanf ("%d%d",&n,&m); for(I=n; i<=m; i++) {IsP=true; for(intj=2; j<i; J + +) { if(I%j = =0&& I! =1) IsP=false; } if(IsP && I! =1) printf ("%d", i); }}intMainvoid) {sxh (); Ispri (); Ispris (); return 0;}
Run as follows:
Find the number of daffodils in the three-digit number
153,370,371,407,
Enter a number to determine if it is prime!
157
157 is prime number
Enter two numbers and output all prime numbers between two numbers!
1 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Determine the number of daffodils, prime numbers (primes)