You have been asked to take a small icon that appears on the screen of a smart telephone and scale it up so it looks bigger on a regular computer screen.
你被要求把手机上的小图标变成电脑上的大的。
The icon will be encoded as characters (x and *) in a 3 × 3 grid as follows:
小图标是:
*x*
xx
* *
Write a program that accepts a positive integer scaling factor and outputs the scaled icon. A scaling factor of k means that each character is replaced by a k × k grid consisting only of that character.
写一个程序把它每一个字符都变成k*k的
The input will be a positive integer k such that k < 25.
输入会是一个正整数k,k<25。
The output will be 3k lines, which represent each individual line scaled by a factor of k and repeated k times. A line is scaled by a factor of k by replacing each character in the line with k copies of the character.
输出会是3k行,详见样例。
3
***xxx***
***xxx***
***xxx***
xxxxxx
xxxxxx
xxxxxx
*** ***
*** ***
*** ***
按照题目要求的缩进
#include<cstdio>
#include<cstdlib>
int main()
{
int k;
scanf("%d",&k);
for(int j=0;j<k;j++)
{
for(int i=0;i<k;i++)
printf("*");
for(int i=0;i<k;i++)
printf("x");
for(int i=0;i<k;i++)
printf("*");
printf("\n");
}
for(int i=0;i<k;i++)
{
for(int m=0;m<k;m++)
printf(" ");
for(int j=0;j<k;j++)
printf("xx");
printf("\n");
}
for(int i=0;i<k;i++)
{
for(int j=0;j<k;j++)
printf("*");
printf(" ");
for(int p=0;p<k-2;p++)
printf(" ");
for(int m=0;m<k;m++)
printf("*");
printf("\n");
}
return 0;
}
#include<cstdio>
#include<cstdlib>
char image[3][4]=
{
"*x*",
" xx",
"* *"
};
int main()
{
int k;
scanf("%d",&k);
for(int i=0;i<3*k;i++)//3k*3k是宽*长,放大之前是3*3
{
for(int j=0;j<3*k;j++)
{
printf("%c",image[i/k][j/k]);
}
printf("\n");
}
return 0;
}