码迷,mamicode.com
首页 > 其他好文 > 详细

codevs——1276 图标缩放

时间:2017-07-18 10:02:21      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:hone   范围   bsp   string   data   repr   电脑   小图标   ram   

1276 图标缩放

 

2012年CCC加拿大高中生信息学奥赛

 时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 青铜 Bronze
 
 
 
题目描述 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>
#include<cstring>
#include<iostream>
using namespace std;
int n;
int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘) f=-1; ch=getchar();}
	while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;  ch=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
	     cout<<"*";
		for(int i=1;i<=n;i++)
		 cout<<"x";
		for(int i=1;i<=n;i++)
		 cout<<"*";
		cout<<endl; 
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
	     cout<<" ";
		for(int i=1;i<=n;i++)
		 cout<<"x";
		for(int i=1;i<=n;i++)
		 cout<<"x";
		cout<<endl; 
	} 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
	     cout<<"*";
		for(int i=1;i<=n;i++)
		 cout<<" ";
		for(int i=1;i<=n;i++)
		 cout<<"*";
		cout<<endl; 
	} 
	return 0;
}

  

codevs——1276 图标缩放

标签:hone   范围   bsp   string   data   repr   电脑   小图标   ram   

原文地址:http://www.cnblogs.com/z360/p/7198572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!