4 条题解
-
2
P905 分离整数的各个数
题面
额……这道题……有多种解……
int类型解
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin>>n; if(n==0){ cout<<0; } while(n!=0){ cout<<n%10<<" "; n/=10; } }
这里还可以存在int数组里,不过属于脱裤子放屁了
string/char类型不讲武德解
#include<bits/stdc++.h> using namespace std; int main(){ string a; cin>>a; for(int i=a.size()-1;i>=0;i--){ cout<<a[i]<<" "; } }
唔……这里也是,string.reverse()函数也是没有必要的,所以省掉这一步直接倒序输出
END
- 1
信息
- ID
- 905
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 377
- 已通过
- 158
- 上传者