主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
我能走到对岸吗
2024年4月22日 00:15
反序数 (C++ 模拟)题解:
P1454
回复 0
|
赞 1
|
浏览 74
#include<bits/stdc++.h> using namespace std; int main() { for(int i = 1000; i <= 9999; i ++) { int t = i * 9; string ans; ans = to_string(t); reverse(ans.begin(), ans.end()); if(i == stoi(ans)) cout << i << endl; } ...
胖乎乎的小猫
2023年1月2日 14:38
P1454-翻转数
P1454
回复 1
|
赞 2
|
浏览 3.9k
这题重点只要会反转就可,求一个数的翻转数: int res=0; while(n!=0){ int t=n%10; res=res*10+t; //这一步其实是可能产生数据溢出问题的,一般要判断后在操作,不过题干所说为4位数,那就不担心了 n=n/10; } return res;
小酒
2024年3月11日 15:51
反序数 题解:
P1454
回复 0
|
赞 0
|
浏览 326
1454解题思路 #include <bits/stdc++.h> using namespace std; int main() { int y,a=1000; int sum=0; while(a<=9999) { int x=a; sum...
Leee0809
2024年3月10日 18:36
反序数 题解:
P1454
回复 0
|
赞 0
|
浏览 195
#include <stdio.h> #include <stdlib.h> int main() { for(int N=1000;N<10000;N++) { int a[4]; int tmp1=N; for(int i=0;i<4...
promising
2024年3月3日 22:13
反序数 题解:
P1454
回复 0
|
赞 0
|
浏览 400
#include<stdio.h> int main() { int N,n; int g,s,b,q; for(N=1000;N<=9999;N++) { q=N/1000; b=N/100%10; &...
黄东龙
2023年10月21日 23:54
反序数 题解:
P1454
回复 0
|
赞 1
|
浏览 947
//冲击北大的第60天 #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<stack> using namespace std; int n,a[1000],b[1000]; int p,q,r,t,l,l1,l2,l3,cnt,tem,ans,sum; string str,str1,str2; char x,y; stack<int>s,s1,s2; ...
活着的传奇
2023年8月17日 16:05
反序数 题解:
P1454
回复 0
|
赞 0
|
浏览 826
从1000开始,到1111就可以结束了,因为1111的九倍是9999.多了就不是四位数了 #include<bits/stdc++.h> using namespace std; int fanxushu(int i){ int b;int s=0; while(i>0){ b=i%10; s=s*10+b; i=i/10; } return s; } int main(){ int i; for(i=1000;i<=1111;i++){ if(i*9==fanxushu(i))...
Hegel
2023年3月17日 19:01
求四位数,它的9倍正好是它的反序数
P1454
回复 0
|
赞 0
|
浏览 3.7k
#include <iostream> using namespace std; int Rev(int n){ int res =0; while(n>0){ res =res*10+n%10; n/=10; } return res; } int main() { for(int i=1000;i<10000;i++) if(9*i==Rev(i)) cout<<i<<" "; return 0; }
落翼
2023年1月21日 15:02
python字符串求解
P1454
回复 0
|
赞 1
|
浏览 2.7k
题目中已经说了是四位数,因此循环从1000开始,大致到1200,因为1200*9已经超过了四位数,反序数也应该是四位 代码如下: for i in range(1000,1200): a = str(i) b = str(i*9) if b==a[::-1]: print(i)
青缘
2022年8月14日 12:05
1454 反序数 获取int的每个位数+字符串前插法与尾插法思想+in
P1454
回复 0
|
赞 1
|
浏览 3.9k
算法思路 使用1234和4321举例 第一个循环 通过取位数的算法,取出1234中的1,和4321中的4 将提取出的int数转化为char 对于1234中的1,采用字符串尾插法:s=s+new_char; 对于4321中的4,采用字符串前插法:s=new_char+s; 重复以上循环,int 1234最终化为string 1234,int 4321最终化为string 1234 判断两者字符串是否相等即可 涉及到的算法:数字取位 1234%10=4; 1234/10=123;...
1
2
题目
反序数
题解数量
12
发布题解
热门题解
1
C++方法
2
P1454-翻转数
3
P1454 - 反序数 - C
4
1454 反序数 获取int的每个位数+字符串前插法与尾插法思想+int转string
5
python字符串求解
6
反序数 题解:
7
反序数 (C++ 模拟)题解:
8
反序数 题解:
9
求四位数,它的9倍正好是它的反序数
10
反序数 题解: