Number of symmetric records

Source: Internet
Author: User
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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.