7 条题解

  • 3
    @ 2023-10-30 11:18:54

    这道题比较简单,而且@qianmo大佬提供的方法和程序也很简单明了了,所以我简单做解释并翻译为python

    python

    from collections import deque
    from typing import Deque
    # 采用collections库的deque数据结构,头弹出的操作更为方便
    
    s: Deque[str] = deque(input())
    ans: str = ''
    
    # while len(s) > 0:
    #     ans += s.popleft()
    #     try:
    #         s.append(s.popleft())
    #     except IndexError:
    #         continue
    # 防止队列空而返回IndexError,可采用try语句
    
    while True:
        ans += s.popleft()
        if len(s) < 1:
            break
        s.append(s.popleft())
    # 这样的循环类似do - while,更为灵活
    
    print(ans)
    
    • 3
      @ 2023-3-8 15:26:34
      #include <bits/stdc++.h>
      using namespace std;
      
      typedef queue<char> qc;
      qc a;
      
      int main()
      {
      	string s;
      	cin >> s;
      	for(auto x:s) a.push(x);
      	string ans = "";
      	while(!a.empty())
      	{
      		ans+=a.front();
      		a.pop();
      		a.push(a.front());
      		a.pop();
      	}
      	cout << ans;
      	return 0;
      }
      
      • 2
        @ 2023-3-21 14:12:06

        s=input()

        q=[0]*200

        head=0

        tail=0

        for i in range(len(s)):

        q[tail]=s[i]
        
        tail+=1
        

        while head<tail:

        print(q[head],end="")
        
        head+=1
        
        q[tail]=q[head]
        
        tail+=1
        
        head+=1
        
        • 1
          @ 2024-10-22 16:00:59
          s=input()
          que=[""]*200
          head,tail=0,0
          for i in range(len(s)):
              que[tail]=s[i]
              tail+=1
          a=""
          while tail!=head:
              print(que[head],end="")
              head+=1
              que[tail]=que[head]
              tail+=1
              head+=1
          
          • 1
            @ 2024-5-29 11:40:47
            s=input()
            que=[""]*100;head,tail=0,0
            for i in range(len(s)):
                que[tail]=s[i]
                tail+=1
            while head<tail:
                print(que[head],end="")
                head+=1
                if head<tail:
                    que[tail]=que[head]
                    tail+=1
                    head+=1
            
            • 1
              @ 2024-3-23 13:39:23

              s=input() q=[0]*200 head=0 tail=0 for i in range(len(s)): q[tail]=s[i] tail+=1 while head<tail: print(q[head],end="") head+=1 q[tail]=q[head] tail+=1 head+=1

              • 0
                @ 2024-5-6 13:54:15

                #逃课( n=input() #换行
                for i in range(1,len(n)):n=n[:i]+n[1+i:]+n[i] #换行
                print(n)

                • 1

                信息

                ID
                815
                时间
                1000ms
                内存
                256MiB
                难度
                1
                标签
                递交数
                938
                已通过
                394
                上传者