[GESP2412三级] 打印数字

星阵问题+二维数组

#include <bits/stdc++.h>
using namespace std;
string str[5][4]={
    ".....","****.",".....",".....",
    ".***.","****.","****.","****.",
    ".***.","****.",".....",".....",
    ".***.","****.",".****","****.",
    ".....","****.",".....","....."
};
int main(){
    string s;
    cin>>s;
    for(int i=0;i<5;i++){
        for(int j=0;j<s.size();j++){
            cout<<str[i][s[j]-'0'];
        }
        cout<<endl;
    }
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	cin>>n;   
	int sum = n.size(); 
	for(int j=0;j<5;j++)      // 控制行
	{	
		string b = n;// "02230"
		for(int i=0;i<sum;i++) // 控制列
		{
			if(b[i]=='0')
			{
				if(j==0||j==4)
				{
					cout<<".....";
				}
				else
				{
					cout<<".***.";
				}	
			}
			else if(b[i]=='1')
			{
				cout<<"****.";
			}
			else if(b[i]=='2')
			{
				if(j==0||j==2||j==4)
				{
					cout<<".....";
				}
				else if(j==1) 
				{
					cout<<"****.";
				}
				else
				{
					cout<<".****";
				}
			}
			else if(b[i]=='3') 
			{
				if(j==0||j==2||j==4)
				{
					cout<<".....";
				}
				else
				{
					cout<<"****.";	
				}
			}
		}
		cout<<endl;
	}
}