游客 Signup | Login
中文 | En

2185 - 打印字符图样(III)

输出以下字符图样
 1   2   3   4  5
 6   7   8   9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

Input

Output

要求每一列数字右对齐,每个数字至少以一个空格分隔。

Examples

Input

no input needed

Output

 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

Solution C

#include<stdio.h>
int main(){
int i=1;
while(i<=25){
    if((i==10)||(i==15)||(i==20)||(i==25)) printf("%d\n",i);
    else if(i==5) printf(" %d\n",i);
    else if(i<=10) printf(" %d ",i);
    else if(i<=25) printf("%d ",i);
    i=i+1;
}
return 0;
}

Solution C++

#include<iostream>
using namespace std;
int main(){
	for(int i=1;i<=10;i++){
		if(i == 1 || i ==6)
			cout<<" "<<i;
		else if( i<10)
			cout<<"  "<<i;
		else
			cout<<" "<<i;
		if(i%5 == 0)
			cout<<endl;
	}
	for(int j=11;j<=25;j++){
		if(j%5 == 0)
		    cout<<j<<endl;
		else
			cout<<j<<" ";
	}
	return 0;	
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题