我这个方法太low了,有大佬能提出意见吗?

P5705 【深基2.例7】数字反转

makeway @ 2024-08-03 14:15:21

代码如下:```cpp

include<bits/stdc++.h>

using namespace std; int main() { int b,c,d; double a,e; cin>>a; b=a/100; c=(a-b100)/10; d=a-b100-c10; e=double(a-b100-c10-d); cout<<e10<<"."<<d<<c<<b<<endl; return 0; }


by qazsedcrfvgyhnujijn @ 2024-08-03 20:24:54

@qazsedcrfvgyhnujijn 要不然就像这个帖子一样乱码


by makeway @ 2024-08-03 20:42:50

题目通过了呀


by ny_123457 @ 2024-08-05 21:50:40

cin>>字符串;

for(i:字符串长度-1---------0)cout<<字符 (LJ式代码)``` //主函数 string n; cin>>n; for(int i=n.size()-1;i>0;i--)cout<<n[i]; return 0;


@[makeway](/user/1413309)

by an_qu_Lei_nuo_yi_er @ 2024-08-05 23:28:00

@makeway ```cpp

include <iostream>

include <cstring>

using namespace std;

int main(){ int t; string n,m; cin>>n; t = n.size() - 1; while(t != -1){ m += n[t]; t--; } cout<<m<<endl; return 0; }


我不知道我的这个好不好

by an_qu_Lei_nuo_yi_er @ 2024-08-05 23:28:37

#include <iostream>
#include <cstring>
using namespace std;

int main(){
    int t;
    string n,m;
    cin>>n;
    t = n.size() - 1;
    while(t != -1){
        m += n[t];
        t--;
    }
    cout<<m<<endl;
    return 0;
}

by jihanyu123 @ 2024-08-07 10:34:05

至于吗?string不香么```

#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    for(int i=s.size()-1;i>=0;i--){
        cout<<s[i];
    }
    return 0;
}

by Jason101 @ 2024-08-12 12:25:15

服了,我这也过了


#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    cout << e << d << c << b << a;
    return 0;
}

by 12345678hzt @ 2024-08-16 18:50:27

用string的特此献上一个函数: reverse(a.begin(),a.end()); a是字符串,c++随便用,c语言不知道,可以逝试。


by gongxiaokaoyan @ 2024-08-27 16:29:49

你的我看不懂思密达

#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin >> s;
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}

by gongxiaokaoyan @ 2024-08-27 16:30:50

@jihanyu123 用reverse 不香吗?


上一页 |