问题 A: Welcome
题目描述
”How happy we are, To meet friends from afar!”
Welcome to Hunan University of Chinese Medicine!
Hope all of you can enjoy the competition ^ v ^
Now your task is to read an integer w and output the character painting of ”HNUCM”, there are w
space(s) (space are represented by dot) between two letters. Please refer to the sample for the specific
format.
输入
There are several test files and each contains one case.
The input contains only 1 integer w (1 ≤ w ≤ 2018).
输出
The output has 5 lines, each line has 25+4w characters which only contains ’o’(lowercase letter ’o’) and
’.’(English period ’.’)
样例输入 Copy
1
样例输出 Copy
o…o.o…o.o…o.ooooo.o…o
o…o.oo…o.o…o.o…oo.oo
ooooo.o.o.o.o…o.o…o.o.o
o…o.o…oo.o…o.o…o…o
o…o.o…o.ooooo.ooooo.o…o
这道题的主要思路就是用一个二维的字符数组,把这些字符存起来。我用到的是一个全局字符数组,存起来之后,我们可以看到每一行你都需要换一次行,然后通过输入的那个数写一个循环,每一个循环里面输出一次英文字符下的句号“.”,然后就可以解决这个问题了。
#include <stdio.h>
/*
o...o.o...o.o...o.ooooo.o...o
o...o.oo..o.o...o.o.....oo.oo
ooooo.o.o.o.o...o.o.....o.o.o
o...o.o..oo.o...o.o.....o...o
o...o.o...o.ooooo.ooooo.o...o
*/
char s[5][26]={ ' ','o','.','.','.','o','o','.','.','.','o','o','.','.','.','o','o','o','o','o','o','o','.','.','.','o',
' ','o','.','.','.','o','o','o','.','.','o','o','.','.','.','o','o','.','.','.','.','o','o','.','o','o',
' ','o','o','o','o','o','o','.','o','.','o','o','.','.','.','o','o','.','.','.','.','o','.','o','.','o',
' ','o','.','.','.','o','o','.','.','o','o','o','.','.','.','o','o','.','.','.','.','o','.','.','.','o',
' ','o','.','.','.','o','o','.','.','.','o','o','o','o','o','o','o','o','o','o','o','o','.','.','.','o'};
int main() {
int n,i,j,k;
scanf("%d",&n);
for(i=0;i<5;i++){
//循环从1到25,会更加直观一点,所以我在设置字符数的时候在前面加了一个空格字符
for(j=1;j<=25;j++){
printf("%c",s[i][j]);
if(j%5==0&&j!=25){
for(k=0;k<n;k++){
printf(".");
}
}
}
printf("\n");
}
}