wikioi 1276 图标的缩放


题目描述 Description

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的

输入描述 Input Description

The input will be a positive integer k such that k < 25.

输入会是一个正整数k,k<25。

输出描述 Output Description

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行,详见样例。

样例输入 Sample Input

3

样例输出 Sample Output

***xxx***

***xxx***

***xxx***

      xxxxxx

      xxxxxx

      xxxxxx
***     ***

***     ***

***     ***

数据范围及提示 Data Size & Hint

按照题目要求的缩进

#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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值