当前位置:网站首页>Blue Bridge Cup Netizen age (violence)

Blue Bridge Cup Netizen age (violence)

2022-07-07 07:17:00 Woodenman Du

Question:

Title Description

This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .

Some Junxin knows a netizen . When asked about age , His netizens said : “ My age is a  22  digit , I'm older than my son  2727  year , If I swap the two digits of my age , It's exactly the age of my son ”

Please calculate : How many possibilities are there for the age of netizens ?

Tips :3030  Age is one of the possibilities .

Operation limit

  • Maximum operation time :1s
  • Maximum running memory : 128M

Result:  7

Solve: Direct violence . There's nothing particular about , There is no need to spend time on optimization .

Code:

#include <iostream>
using namespace std;
int main()
{
  int cnt = 0;
  for(int i = 28; i <98; i++)
  {
    int temp = i,ans = 0;
    while(temp){
        ans *= 10;
        ans += temp%10;
        temp /= 10;
    }
    if(i - ans == 27) cnt++;
  }
  cout <<cnt;
  return 0;
}

Statement : For the purpose of sorting out personal questions , In case of infringement , Please contact to delete ~

原网站

版权声明
本文为[Woodenman Du]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130713287179.html