10 条题解

  • 0
    @ 2025-4-13 20:23:01

    核心:先把每个字符转成 ASCII 编码,再次、逐个输出

    /*
    
    */
    #include<bits/stdc++.h>
    #define ll long long
    #define elif else if
    using namespace std;
    const int N=300005;
    
    const char hello_world[12]=
    {'H','e','l','l','o',','
    ,'W','o','r','l','d','!'};
    // 定义字符数组
    
    signed main(){
        
        ios::sync_with_stdio(0);
        cin.tie();
        cout.tie();
        // 关闭输入输出流同步,减少输入输出时间
        
    #ifdef downline_judge
        freopen("helloworld.in","r",stdin);
        freopen("helloworld.out","w",stdout);
    #endif
        // 在本地编译器上打开文件输入输出
        
        const char* p=hello_world;
        // 定义指针变量数组
        
        short chascii[12]={0};
        // ASCII编码数组
        // 由于ASCII编码范围只是从-128~127
        // 所以可以用short
        
        for(int i=0;i<12;i++){
            chascii[i]=(int)hello_world[i];
        }
        // 转化成ASCII编码
        
        for(int i=0;i<12;i++){
            cout<<(char)chascii[i];
        }
        // 将ASCII编码转化成char字符逐个输出
        
        return 0;
        // 完结撒花
    }
    

信息

ID
4452
时间
1000ms
内存
128MiB
难度
1
标签
(无)
递交数
1151
已通过
624
上传者