1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自分専用、文字の並びを逆にする。4文字まで

Last updated at Posted at 2025-04-19
  • UNO での 予定は、未定
  • 簡単な文字操作

プログラム

オンラインコンパイラpaiza


#include <iostream>
using namespace std;

void r(char *str){
    
    char c;
    
    if(str[0] == 0 ) return;
    if(str[1] == 0 ) return;
    if(str[2] == 0 ) {
        c = str[0];
        str[0] = str[1];
        str[1] = c;
        return;
    }
    if(str[3] == 0 ) {
        c = str[0];
        str[0] = str[2];
        str[2] = c;
        return;
    }
    if(str[4] == 0 ) {
        
        c = str[0];
        str[0] = str[3];
        str[3] = c;
        
        c = str[1];
        str[1] = str[2];
        str[2] = c;
        
        return;
    }
    
    
}

int main(void){
    // Your code here!
    
    char s0[32] = "";
    char s1[32] = "1";
    char s2[32] = "12";
    char s3[32] = "123";
    char s4[32] = "1234";

    
    printf("START\n");
    r(s0);printf("%s\n",s0);
    r(s1);printf("%s\n",s1);
    r(s2);printf("%s\n",s2);
    r(s3);printf("%s\n",s3);
    r(s4);printf("%s\n",s4);
}



START

1
21
321
4321



1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?