3286:【例47.1】 倒序数
[例 47.1] 倒序数
1160:倒序数
1160:倒序数
倒序数(信息学奥赛一本通-T1160)_哔哩哔哩_bilibili
scratch3代码:
C语言代码:
/*
3286:【例47.1】 倒序数
http://bas.ssoier.cn:8086/problem_show.php?pid=3286
1160:倒序数[递归]
https://blog.csdn.net/Tristal2010/article/details/121732187
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int a(int y)//用来算最高为的函数
{
int i;
for(i=10;y/i>=10;i*=10)//一直缩位
{}
return i;//最后输出
}
int d(int x) //运用递归的d函数
{
if(x<10) //停止的条件
return x;
else //递归关系式
return (x%10)*a(x)+d(x/10);
}
int main() //主函数
{
int a;//要被倒序的数
scanf("%d",&a);
printf("%d",d(a));
return 0;
}
C++代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
for(int i=s.size()-1;i>=0;i--){
cout<<s[i];
}
return 0;
}
/*
3286:【例47.1】 倒序数
http://bas.ssoier.cn:8086/problem_show.php?pid=3286
1160:倒序数[递归]
https://blog.csdn.net/Tristal2010/article/details/121732187
*/
#include<iostream> //使用iostream库
#include<cstdio> //使用cstdio库
using namespace std;
int a(int y)//用来算最高为的函数
{
int i;
for(i=10;y/i>=10;i*=10)//一直缩位
{}
return i;//最后输出
}
int d(int x) //运用递归的d函数
{
if(x<10) //停止的条件
return x;
else //递归关系式
return (x%10)*a(x)+d(x/10);
}
int main() //主函数
{
int a;//要被倒序的数
cin>>a;//输入
cout<<d(a);//输出
return 0;
}
python3代码:
def dxs(n):
print(n%10,end='')
if n>=10:
dxs(n//10)
n=input()
n=int(n)
dxs(n)
3100:【例18.3】 卡牌游戏
3101:练18.1 还要等多久
3102:练18.2 苹果和虫子
1.3_15苹果和虫子
3103:练18.3 组别判断
3104:练18.4 计算邮资
3105:【例19.1】 鸡兔同笼
3106:【例19.2】 判断身材
3107:【例19.3】 田忌赛马
练 19.1 整数大小比较
3108:练19.1 整数大小比较
3109:练19.2 三个数