zoukankan      html  css  js  c++  java
  • HDU 4706 Children's Day

    Children's Day

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 315 Accepted Submission(s): 196


    Problem Description
    Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' is constituted by two vertical linesand one diagonal. Each pixel of this letter is a character orderly. No tail blank is allowed.
    For example, this is a big 'N' start with 'a' and it's size is 3.
    a e
    bdf
    c g
    

    Your task is to write different 'N' from size 3 to size 10. The pixel character used is from 'a' to 'z' continuously and periodic('a' is reused after 'z').
     
    Input
    This problem has no input.
     
    Output
    Output different 'N' from size 3 to size 10. There is no blank line among output.
     
    Sample Output
    [pre] a e bdf c g h n i mo jl p k q ......... r j [/pre]
    Hint
    Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
     
    Source
     


     

    读题很重要.... 我看了半天, 输出倒数第二行虚线是什么意思...  读了半天,参反应过来,那只是省略了 一些字符...

    哎... 看来还需要做做练习....

     总之水题一道....

    import java.io.*;
    import java.util.*;
    
    public class Main {
    
    	public static void main(String[] args) {
    		new Main().work();
    	}
    
    	void work() {
    		char c = 'a';
    		//求第一列数据
    		for (int i = 3; i <=10; i++) {
    			char[][] ch = new char[i][i];
    			for (int j = 0; j < i; j++) {
    				
    				ch[j][0] = c;
    				c=(char) ((c + 1));
    				if (c > 'z')
    					c = 'a';
    			}
    			//求 第二列 到 倒数第二列
    			for (int k = i - 2, j = 1; k > 0 && j < i - 1; k--, j++) {
    				
    				ch[k][j] = c;
    				c=(char) ((c + 1));
    				if (c > 'z')
    					c = 'a';
    			}
    			//求最后一列
    			for (int j = 0; j < i; j++) {
    				
    				ch[j][i - 1] = c;
    				c=(char) ((c + 1));
    				if (c > 'z')
    					c = 'a';
    			}
    			//输出
    			for (int j = 0; j < i; j++) {
    				for (int k = 0; k < i; k++) {
    					if (ch[j][k] >= 'a' && ch[j][k] <= 'z')
    						System.out.print(ch[j][k]);
    					else
    						System.out.print(" ");
    				}
    				System.out.println();
    			}
    		}
    
    	}
    }
    


     

  • 相关阅读:
    [P1034][NOIP2001]一元三次方程求解 (二分)
    考前停课集训 Day7 嘞
    [P4995]跳跳!(贪心)
    [P4994]终于结束的起点 (递推)
    考前停课集训 Day6 垒
    [BZOJ1899][ZJOI2004]Lunch 午餐 (DP)
    考前停课集训 Day5 累
    任务查询系统 【主席树】
    主席树入门
    HNOI2002 营业额统计 平衡树模板题 【splay】
  • 原文地址:https://www.cnblogs.com/riskyer/p/3310667.html
Copyright © 2011-2022 走看看