//Title 13: Print out all the "daffodils", the so-called "Narcissus number" refers to a three-digit number, its number of cubic and equal to the number//itself. For example: 153 is a "narcissus number", because 153 = 1 of the three times +5 three of the +3-time square. #define_crt_secure_no_warnings#include<stdio.h>#include<stdlib.h>#include<math.h>//Analysis: First prepare a dynamic memory array to store all three digits, this three bit hundreds of bit can not be 0//to facilitate decomposition, first define the structure//then get the Hundred, num/100, get 10 bits, (num-hundred *100)/10, digit is (num-hundred *100-10 bit *10)//break out the number of bits, 10, hundred, to see if the daffodils are satisfied//use of the POW () functionstructnarcissunum{intHundred; intTen; intIndiv;};voidMain () {//Defining dynamic Arrays structNarcissunum *p =malloc(sizeof(structNarcissunum) * -); structNarcissunum num,*PN; PN= # //3 cycles to build all three-digit numbers intm =0; for(inti =1; I <Ten; i++) { for(intj =0; J <Ten; J + +) { for(intK =0; K <Ten; k++) { if((int) (Pow (i,3.0) + (int) Pow (J,3.0) + (int) Pow (k,3.0) = = (I * -+ J *Ten+k)) {PN->hundred =i; PN->ten =J; PN->indiv =K; * (p + m) = *PN; M++; } } } } for(inti =0; I < m; i++) {printf ("\n%d%d%d", (P + i)->hundred, (P + i)->ten, (P + i)indiv); } System ("Pause");}View Code
//Topic 14: Decomposition of a positive integer factorization. For example: Enter 90 and print out 90=2*3*3*5. #define_crt_secure_no_warnings#include<stdio.h>#include<stdlib.h>#include<math.h>//Analysis: First find the factor of this integer, and then the factor, until the value can not be evaluated, recursive call---- This thinking error //positive integer decomposition factorization, if small to large decomposition, there will be no (can be decomposed factor)voidMain () {intnum =0; intindex =0; scanf ("%d", &num); printf ("\ n"); //index = (int) sqrt ((double) (num+1)); for(inti =2; I <= num; i++) { while(1){ if(num%i = =0) { if(num/i==1) {printf ("%d", i); } Else{printf ("%d*", i); } num= num/i; } Else{ Break; }}} System ("Pause");}
//Topic 15: Use the nesting of conditional operators to complete this problem: the students of the academic score >=90 A, 60-89 points between the use of B,//60 points or less is indicated in C. #define_crt_secure_no_warnings#include<stdio.h>#include<stdlib.h>#include<math.h>//you can use if nested or switch statements to completevoidProtect1 (intnum) { if(Num >= -) {printf ("A"); } Else if(Num >= -) {printf ("B"); } Else{printf ("C"); }}voidProtect2 (intnum) { inttemp = num/Ten; Switch(temp) { Case 9: printf ("A"); Break; Case 8: Case 7: Case 6: printf ("B"); Break; default: printf ("C"); Break; }}voidMain () {intnum =0; scanf ("%d",&num); printf ("\ n"); Protect2 (num); System ("Pause");}
C language Tempered 5