主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
我能走到对岸吗
2024年4月24日 00:34
翻转数的和 题解:
P1003
回复 0
|
赞 1
|
浏览 55
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL a, b; LL ans; int main() { while(cin >> a >> b) { string s1 = to_string(a), s2 = to_string(b); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); a = stol(s1), b = ...
15240928957
2024年4月2日 16:36
c++
P1003
回复 0
|
赞 0
|
浏览 112
#include <bits/stdc++.h> using namespace std; int fz(int n) { int w =0; while(n>0) { w=w*10; w+=n%10; n=n/...
Djiangxu
2024年3月21日 11:59
翻转数的和 题解:取余取整求位值,乘以翻转后的位权相加即可得到翻转数。
P1003
回复 0
|
赞 0
|
浏览 204
解题思路:输入一个数如123我们可以通过求它的余数(123%10)来获得个位3,而它的翻转数321的百位刚好是(3 * 10 * 10),十位是(2 * 10),以此类推。 这里我们可以看出,原数位数是3,而3 * 100 = 3 * (10 ^(3 - 1)),可以写一个函数得到原数的位数,然后根据前面的关系求出翻转数的每个位数,用一个以0为初始值的变量依次接收各个位数的值便可得到翻转数。 代码如下所示: #include<iostream> using namespace std; int getn(int n){ &n...
zhangan
2024年3月20日 16:52
翻转数的和 题解:
P1003
回复 0
|
赞 0
|
浏览 177
#include <stdio.h> #include <stdlib.h> int fun(int n) { int res = 0; while (n) { res = res * 10 + n % 10; n = n / 10; } return res; } int main() { &nbs...
CGaaraY
2024年3月17日 16:38
翻转数的和 题解:将字符串转int型,甚至可以忽略翻转,因为默认从最高
P1003
回复 0
|
赞 0
|
浏览 200
#include <iostream> #include <cmath> #include <string> #include <algorithm> #include <vector> using namespace std; int main() { string A, B; while(cin >> A >> B) { long long C = 0,D = 0; for (int i = 0; ...
FCC
2024年3月15日 20:11
翻转数的和 题解:使用int型+数字翻转(除留余数法)
P1003
回复 0
|
赞 0
|
浏览 180
#include <bits/stdc++.h> using namespace std; //求翻转数 int reverse( int n ){ int x, sum = 0; while( n > 0 ){ x = n % 10; //个位余数 sum = sum * 10 + x; //右移1位所以要×10,再加上当前余数 n /= 10; //右移1位 } return sum; } int main(){ int a, b; while( cin >> a &...
小酒
2024年3月15日 16:15
翻转数的和 题解:
P1003
回复 0
|
赞 1
|
浏览 144
1003解题思路 #include <bits/stdc++.h> using namespace std; int jisuan(int m) { int j=0,x=0; while(m%10==0) { m=m/10; } while(m>0) { j=m%10; m=m/10; x=x*10+j; } return x; } int main() { int a,b; while(cin>>a>>b) { int sum=0...
zx142407789
2024年3月15日 13:02
翻转数的和 题解:自用笔记
P1003
回复 0
|
赞 1
|
浏览 165
#include<stdio.h> #include<stdlib.h> int inverse(int n) { int len = 0; int m = n; int input = 0; while (m > 0) {//判断是几位数 m /= 10; len++; } int *arr = malloc(sizeof(int) * len);//分配一个数组来存储各位对应的数字 for (int i = 0; i < len; i++) { arr[i] = n % 10; n...
FIVEszc
2024年3月11日 20:52
翻转数的和 题解: 实质就是拆分每个数
P1003
回复 0
|
赞 0
|
浏览 147
#include<bits/stdc++.h> using namespace std; int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF){ int c=0,d=0; while(a>0) { c=c+a%10; c*=10; a/=10; } c/=10; while(b>0) { d=d+b%10; d*=10...
williams
2024年3月9日 09:23
翻转数的和 题解:C
P1003
回复 0
|
赞 0
|
浏览 141
封装成函数更简洁一点 #include <stdio.h> #include <math.h> int main(){ int n1,t1,t2,n2; while(scanf("%d %d",&n1,&n2)!=EOF){ int sum1=0,sum2=0,len1=0,len2=0; t1 = n1; t2 = n2; while(t1>0){ t1 /= 10; ...
1
2
3
4
题目
翻转数的和
题解数量
33
发布题解
热门题解
1
P1003 - 翻转数的和 - C
2
简洁~~,_(:ι」∠)_好饿,但是不想动
3
有点耍滑头,但是姑且能通过。
4
利用sscanf()实现
5
运用字符串函数stoi直接转为整数再相加
6
翻转数的和 题解:自用笔记
7
只包括函数和循环方法,比较前面两位较易懂因为我是大一学生语言较简单。
8
翻转数的和 题解:
9
翻转数的和 题解:
10
翻转数的和 题解: 实质就是拆分每个数