竞赛
考级
入门题解11,我的代码如下: 具体的重点部分我写在了**入门题解9(1)**里,想了解更多的可以到网址:链接描述 入门题解9网址:https://www.acgo.cn/problemset/327/1342?tab=explanation(可以复制粘贴到搜索框里,进入网址
考虑拆位,如下: 当然也可以使用字符串,此处不多加赘述。
代码如下
我,新秀答案共享师(编程地板砖),期待你滴官主(和赞)(acgo觉得很赞)
空降坐标:CP002975 请看代码
简单
A329.反转数字
AC代码:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 代码如下: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
时间复杂度O(n)
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int x=0,y=n; while(y!=0){ x*=10; x+=y%10; y=y/10; } cout<<x; return 0; }
#include<bits/stdc++.h>//submitRecord// using namespace std; //const int N=1e7+10; int main(){ //freopen("","r",stdin); //freopen("","w",stdout); ios::sync_with_stdio(); cin.tie(nullptr); cout.tie(nullptr); int n,sum=0; cin>>n; while(n!=0){ sum=sum*10+n%10; n/=10; } cout<<sum; //fclose(stdin); //fclose(stdout); return 0; }
提交答案之后,这里将显示提交结果~