蓝桥——商标倒放

// test.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include <stdio.h>
#include<sstream>
using namespace std;

void i2s(int n, string &s) {
    stringstream ss;
    ss << n;
    ss >> s;
}

int reverse(int n) {
    string s;
    int a;
    i2s(n, s);
    if (s[0] == '0')return -1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '3' || s[i] == '4' || s[i] == '7')
            return -1;
        else if (s[i] == '6')s[i] = '9';
        else if (s[i] == '9')s[i] = '6';
    }
    int temp;
    for (int i = 0; i < s.length()/2; i++) {
        temp = s[i];
        s[i] = s[s.length() - i - 1];
        s[s.length() - 1 - i] = temp;
    }
    stringstream ss;
    ss << s;
    ss >> a;
    return a;
}

int main()
{

    //int a = reverse(1958);
    //cout << a;
    
    /*
    
    
    */
    int a8[10000] = { 0 };//存放赚了800多的
    int a2[10000] = { 0 };//存放赔了200多的
    int az = 0, ap = 0;//赚,陪数组下标
    int n;
    for (n = 1000; n <= 9999; n++) {
        int rn=reverse(n);
        if (rn == -1)continue;
        else if (rn - n > 800 && rn - n < 900) {
            a8[az++] = n;
        }
        else if (rn - n > -300 && rn - n < -200) {
            a2[ap++] = n;
        }
    }


    for(int i=0;a8[i]!=0;i++)
        for (int j = 0; a2[j] != 0; j++) {
            if (-a8[i] + reverse(a8[i]) - a2[j] + reverse(a2[j]) == 558)cout << a2[j]<<endl;
        }
    
    
    
    
    return 0;
}

9088

转载于:https://www.cnblogs.com/ZengWeiHao/p/10485548.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值