Question
Description: print all the numbers (n <256) whose square is symmetric. For example, 11*11 = 121 input: no input data output: the number of outputs with the topic requirements. If there are more than one group of output data, separate them by carriage return. Sample input: sample output:
Ideas
- Checks whether the data in the array meets the symmetric nature.
- Returns the remainder of an integer to a single digit.
AC Code(C)
# Include <stdio. h> # include <stdlib. h> int judgesyry ry (INT square); int main () {int I; for (I = 0; I <256; I ++) {if (I = 0) {printf ("0 \ n");} else {If (judgesyry ry (I * I) printf ("% d \ n", I) ;}} return 0 ;} /*** Description: determines whether square meets the symmetric nature */INT judgesyry ry (INT square) {int I, j, flag, arr [10]; // put each square in an array for (I = 0; Square; I ++, square/= 10) {arr [I] = square % 10 ;} // determine whether the array conforms to the symmetric for (flag = 1, j = I/2 ; J> = 0; j --) {If (ARR [J]! = Arr [I-1-J]) {flag = 0; break ;}} return flag ;}