为什么就不对呢????

P5730 【深基5.例10】显示屏

LiBinnn @ 2020-03-16 16:23:21

#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

string line1[10] = {"XXX","..X","XXX","XXX","X.X","XXX","XXX","XXX","XXX","XXX"};
string line2[10] = {"X.X","..X","..X","..X","X.X","X..","X..","..X","X.X","X.X"};
string line3[10] = {"X.X","..X","XXX","XXX","XXX","XXX","XXX","..X","XXX","XXX"};
string line4[10] = {"X.X","..X","X..","..X","..X","..X","X.X","..X","X.X","..X"};
string line5[10] = {"XXX","..X","XXX","XXX","..X","XXX","XXX","..X","XXX","XXX"};
int main(){
    string str;
    int num[200];
    int n;
    cin>>n;
    getchar();
    getline(cin,str);
    for(int i=0;i<n;i++){
        num[i] = str[i]-'0';
    }

    //1
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<line1[num[i]];
        }else{
            cout<<line1[num[i]]<<".";
        }
    }
    cout<<endl;
    //2
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<line2[num[i]];
        }else{
            cout<<line2[num[i]]<<".";
        }
    }
    cout<<endl;
    //3
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<line3[num[i]];
        }else{
            cout<<line3[num[i]]<<".";
        }
    }
    cout<<endl;
    //4
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<line4[num[i]];
        }else{
            cout<<line4[num[i]]<<".";
        }
    }
    cout<<endl;
    //5
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<line5[num[i]];
        }else{
            cout<<line5[num[i]]<<".";
        }
    }
    return 0;
} 

by 胡萝卜兔 @ 2020-03-27 22:54:41

@LiBinnn 打两个getchar()就好了


上一页 |