19 条题解

  • 9
    @ 2022-8-16 18:09:53

    这一道题一遍过哈~来吧,上思路!

    1. 建立长度为 255 的字符数组 a
    2. 老样子,cin.getline() 输入一下下
    3. 然后从尾到头遍历一下就可以啦~
    4. 注意!:getline是从 0 开始输入的哦~

    好了上代码!(每次都AC过的UP看着你)

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    	char a[255];
        cin.getline(a, 255, '\n');
        for (int i = strlen(a) - 1; i >= 0; i--) cout << a[i];
    	return 0;
    }
    
    • 3

      很简单的一道题:

      #include <bits/stdc++.h> 
      using namespace std;
      int main()
      {
      	
      	string a;
      	cin >> a;
      	for (int i = a.length() - 1;i >= 0;i--)
      	{
      		cout << a[i];
      	}
      	return 0;
      }
      
    • 2
      @ 2022-4-3 16:35:30
      
      
      就跟数组的倒序输出一样,从最后一个字符开始遍历即可
      
      注意是int i=s.length()-1
      • 1
        @ 2024-1-20 10:18:20

        其实用不着用数组,字符串就行啦~

        已AC,请放心食用

        #include <iostream>
        using namespace std;
        int main()
        {
            string n;
            cin >> n;
            for (int i = n.length() - 1; i >= 0; i--)
            {
                cout << n[i];
            }
            return 0;
        }
        

        养成好习惯,看后点个赞!

        • 1
          @ 2023-11-19 13:59:06

          【python思路】本题考核字符串切片知识 1、输入一行字符串 2、从尾部倒着输出整个字符串

          s = input()
          print(s[::-1])
          
          • 1
            @ 2023-9-3 10:19:56

            hahahi!劳资来了!today我特意上代码x3,敬请查收!

            1.level 1:普通版(字符串倒序)

            (读者):(⊙﹏⊙)呃……

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

            2.level 5:进阶版(递归)

            (读者):(ˉ▽ ̄~) 切~~

            #include <bits/stdc++.h>
            using namespace std;
            string s;
            void print(int k)
            {
                if (k < 0) return;
                cout << s[k];
                print(k - 1);
            }
            int main()
            {
                getline(cin,s);
                print(s.size());
            }
            

            3.level 1000000000000000000000000000:魔鬼版(字符双向链表)

            (读者):!!!!!!!!!

            #include <bits/stdc++.h>
            using namespace std;
            struct jiji
            {
                char shu;
                struct jiji *hou,*xian;
            };
            int main()
            {
                struct jiji *p,*q,*tou,*t,*tail;
                tou = NULL;
                tail = NULL;
                char k;
                q = tou;
                while (cin >> k)
                {
                    p = (struct jiji *)malloc(sizeof(struct jiji));
                    p->shu = k;
                    if (tou == NULL) tou = p;
                    else p->xian = q;
                    p->hou = NULL;
                    q = p;
                }
                tail = q;
                t = tail;
                while (t != tou)
                {
                    printf("%c",t->shu);
                    t = t->xian;
                }
                printf("%c",tou->shu);
            }
            

            🆗,byebye!

            • 1
              @ 2023-8-30 11:00:38

              过辣!

                  string a;
                  cin>>a;
                  for (int i=a.length()-1;i>=0;i--)//倒着遍历字符串a的每一位下标。
                  {
                      cout<<a[i];//输出时可以直接用i做下标
                  }
              
              • 1
                @ 2023-8-4 21:12:29

                L2小萌新预习完来练手啦😄

                本Level坠简单的字符串练习!

                上代码🚀️

                #include <bits/stdc++.h>
                using namespace std;
                int main()
                {
                string a;
                cin >> a;
                for (int i = a.length() - 1;i >= 0; i--) cout << a[i];//直接倒序输出
                return 0;
                }
                

                抱歉啊友友们,真不会讲了👀️

                • 1
                  @ 2023-7-23 11:35:15
                  #include <bits/stdc++.h>
                  using namespace std;
                  int main(){
                      string a;
                      cin>>a;
                      int b = a.length();
                      for (int i = b-1;i>=0;i--){
                          cout<<a[i];
                      }
                  }
                  已AC,放心食用
                  
                  • 1
                    @ 2022-8-13 21:23:18
                    #include<bits/stdc++.h>
                    using namespace std;
                    int main()
                    {
                        string s;
                        cin>>s;//输入
                        int n=s.size();
                        for(int i=n-1;i>=0;i--)
                        {
                            cout<<s[i];
                        }
                    }
                    

                    当然,在计算长度时,也可以用s.length()来计算,只不过运用s.size()时,要用万能头文件,否则会出错

                    • 1
                      @ 2022-8-2 18:02:13
                      越来越简单了~
                      这道题的代码↓
                      string a;
                      cin >> a;
                      for (int i = a.length() - 1; i >= 0; i--)//倒序
                      {
                          cout << a[i];
                      }
                      八月的第三个题解!!!
                      • 0
                        @ 2024-2-1 15:35:17

                        没人会用reverse吗

                        #include <bits/stdc++.h>
                        using namespace std;
                        string s;
                        int main(){
                            getline(cin,s);
                            reverse(s.begin(),s.end());
                            cout<<s;
                        }
                        
                        • 0
                          @ 2023-7-8 12:52:11

                          #include <iostream> #include <string> using namespace std; int main() { string a; getline(cin, a); for (int i = a.size() - 1; i >= 0; i--) { cout << a[i]; } return 0; }

                          • 0
                            @ 2023-4-2 19:39:03

                            没有空格情况下对,有的话得用getline(刚查的())

                            #include<bits/stdc++.h>
                            using namespace std;
                            int main()
                            {
                                string s;
                                cin>>s;
                                for (int i=s.length()-1;i>=0;i--)
                                    cout<<s[i];
                                return 0;
                            }
                            
                            • 0
                              @ 2023-2-25 10:31:26

                              试试作弊

                              #include <bits/stdc++.h>
                              using namespace std;
                              int main()
                              {
                                  cout << "asdfghjkl123456";
                                  return 0;
                              }
                              
                              • 0
                                @ 2023-1-2 20:11:54

                                以下是这题的思路:

                                1.定义一个 string类型变量s。 2.输入。

                                3.从尾到头遍历🏪一下(注意循环范围从s.length() - 1到0)。

                              • 0
                                @ 2022-12-31 19:39:31

                                非常简单,上代码!

                                #include <iostream>
                                using namespace std;
                                int main()
                                {
                                    string n;
                                    cin >> n;
                                    for (int i = n.length() - 1;i >= 0;i--)
                                    {
                                        cout << n[i];
                                    }
                                    return 0;
                                }
                                
                                • -1
                                  @ 2023-8-2 19:17:27

                                  上代码!

                                  #include <bits/stdc++.h>
                                  using namespace std;
                                  int main()
                                  {
                                      cout << "asdfghjkl123456" << endl;
                                      return 0;
                                  } //已AC
                                  

                                  熟悉到吐的抱走流程:点赞 → 抱走

                                  • -4
                                    @ 2022-8-22 18:26:20

                                    回文数:我无敌!

                                    • @ 2022-12-31 19:40:27

                                      这就是传说中的......无代码题解?

                                  • 1

                                  信息

                                  ID
                                  120
                                  时间
                                  1000ms
                                  内存
                                  64MiB
                                  难度
                                  3
                                  标签
                                  递交数
                                  859
                                  已通过
                                  454
                                  上传者