12月16号下午去暴风音影面试.有一道题不会写?
问题是这样的?
打印图形:#########*##################*#########
########***################***########
#######*****##############*****#######
######*******############*******######
#####*********##########*********#####
####***********########***********####
###*************######*************###
##***************####***************##
#*****************##*****************#
**************************************
请高手帮忙? 

解决方案 »

  1.   


    public class Test{
    public static void main(String [] args){
    System.out.println("#########*##################*#########");
    System.out.println("########***################***########");
    System.out.println("#######*****##############*****#######");
    System.out.println("######*******############*******######");
    System.out.println("#####*********##########*********#####");
    System.out.println("####***********########***********####");
    System.out.println("###*************######*************###");
    System.out.println("##***************####***************##");
    System.out.println("#*****************##*****************#");
    System.out.println("**************************************");
    }
    }
      

  2.   

    public class FaXing {
    public static void main(String[] args) {
    String src="#########*#########";
    for(int i=0;i<10;i++){//28 9
    print(line(src,9-i,9+i));
    print(line(src,9-i,9+i));
    System.out.println();
    } }
    private static char[] line(String src,int begin,int end){
    char []c=src.toCharArray();
    for(int i=0;i<c.length;i++){
    if(i>=begin&&i<=end){
    c[i]='*';
    }
    }
    return c;
    }
    private static void print(char[] a){
    for(char i:a)
    System.out.print(i);
    }
      

  3.   


    public static void main(String... args) {
    String str = "%1$s%2$s%1$s%1$s%2$s%1$s";
    int N = 10;
    for (int i = 0, j = N; i < N; i++, j -= 2) {
    System.out.println(String.format(str, getStr(N - i - 1, '#'), getStr(i * 2 + 1, '*')));
    }
    } private static String getStr(int n, char c) {
    if (n <= 0) return "";
    char[] ch = new char[n];
    Arrays.fill(ch, c);
    return String.valueOf(ch);
    }#########*##################*#########
    ########***################***########
    #######*****##############*****#######
    ######*******############*******######
    #####*********##########*********#####
    ####***********########***********####
    ###*************######*************###
    ##***************####***************##
    #*****************##*****************#
    **************************************
      

  4.   


    public static void main(String... args) {
    output(16,'#','*');

    private static void output(int n, char ch1, char ch2) {//仅支持N<17
    long i = 1;
    i = (i << (n-1)) | (i << (3*n-2));
    for (int j = 0; j < n; j++) {
    String s = Long.toString(i,2);
    s = s.substring(s.lastIndexOf('1') + 1) + s;
    System.out.println(s.replace('0', ch1).replace('1', ch2));
    i = (i << 1) | (i >> 1) | i;
    }

    }###############*##############################*###############
    ##############***############################***##############
    #############*****##########################*****#############
    ############*******########################*******############
    ###########*********######################*********###########
    ##########***********####################***********##########
    #########*************##################*************#########
    ########***************################***************########
    #######*****************##############*****************#######
    ######*******************############*******************######
    #####*********************##########*********************#####
    ####***********************########***********************####
    ###*************************######*************************###
    ##***************************####***************************##
    #*****************************##*****************************#
    **************************************************************
      

  5.   

    接分哈。public static void test4()
        {
            //显示行数
            int n = 10;
            
            //每行共共显示元素个数
            int k = (n * 2 - 1) * 2;
            
            //第一个列表中间下标
            int m1 = (k / 2 + 1) / 2;
            
            //第二个列表中间下标
            int m2 = (k / 2 + 1) + m1 - 1;
            
            for(int i = 0;i < n;i++)
            {
                for(int j = 1;j <= k;j++)
                {
                    if((j < m1 - i || j > m1 + i)
                           && (j < m2 - i || j > m2 + i))
                    {
                        System.out.print("#");
                    }
                    else
                    {
                        System.out.print("*");
                    }
                }
                System.out.println();
            }
        }
      

  6.   

    StringBuilder str1 = new StringBuilder("#########");
    StringBuilder str2 = new StringBuilder("*");
    StringBuilder str3 = new StringBuilder("##################");
    System.out.print(str1);
    System.out.print(str2);
    System.out.print(str3);
    System.out.print(str2);
    System.out.print(str1);
    System.out.println();
    while (str1.length() > 0) {

    str1.delete(0, 1);
    str2.append("**");
    str3.delete(0, 2);

    System.out.print(str1);
    System.out.print(str2);
    System.out.print(str3);
    System.out.print(str2);
    System.out.print(str1);
    System.out.println();
      

  7.   

    public class FaXing {
        public static void main(String[] args) {
            String src="#########*#########";
            for(int i=0;i<10;i++){//28 9
                print(line(src,9-i,9+i));
                print(line(src,9-i,9+i));
                System.out.println();
            }    }
        private static char[] line(String src,int begin,int end){
            char []c=src.toCharArray();
            for(int i=0;i<c.length;i++){
                if(i>=begin&&i<=end){
                    c[i]='*';
                }
            }
            return c;
        }
        private static void print(char[] a){
            for(char i:a)
            System.out.print(i);
        }
    }
      

  8.   

    支持所有大于零的奇数(1除外)
    public class PrintTest {

    public static void main(String[] args){
    PrintTest pt = new PrintTest();
    pt.printit(11);
    }

    public void printit(int number){
    if(number%2 != 1){
    return;
    }
    int  = number/2;
    for(int i = 0;i <= ;i++){
    this.printLine(, i);
    }

    }

    public void printLine(int len,int change){
    this.printWell(len - change);
    this.printStar(1 + 2*change);
    this.printWell(len - change);
    this.printWell(len - change);
    this.printStar(1 + 2*change);
    this.printWell(len - change);
    System.out.println();
    }

    public void printStar(int i){
    while(i > 0){
    System.out.print("*");
    i--;
    }
    }
    public void printWell(int i){
    while(i > 0){
    System.out.print("#");
    i--;
    }
    }}
      

  9.   

    public static void test4()
        {        int n = 10;
            int k = (n * 2 - 1) * 2;
            int m1 = (k / 2 + 1) / 2;
                   int m2 = (k / 2 + 1) + m1 - 1;
           
            for(int i = 0;i < n;i++)
            {
                for(int j = 1;j <= k;j++)
                {
                    if((j < m1 - i || j > m1 + i)
                          && (j < m2 - i || j > m2 + i))
                    {
                        System.out.print("#");
                    }
                    else
                    {
                        System.out.print("*");
                    }
                }
                System.out.println();
            }
        }
      

  10.   

    #include <stdio.h>
    #include <time.h>void print(int rownumber)
    {
        int i;//line number
        int j;//first # number
        int k;//first * number
        int m;//second # number
        int n;//second * number
        int l;//third # number
        int =rownumber-1;
        for(i=0;i<rownumber;i++)
        {
            for(j=0;j<-i;j++)
            {
             printf("#");
    }
    for(k=0;k<2*i+1;k++)
    {
    printf("*");
    }
    for(m=0;m<2*(-i);m++)
    {
    printf("#");
    }
    for(n=0;n<2*i+1;n++)
    {
    printf("*");
    }
    for(l=0;l<-i;l++)
    {
    printf("#");
    }
    printf("\n");
        }
    }int main()
    {
    int num;
    printf("please input the number of total lines!\n");
    scanf("%d",&num);
    print(num);
    }
      

  11.   

    菜鸟也来凑热闹                   
                       for(int m=0;m<10;m++){
    for(int n=0;n<40;n++){
    if(n<9-m||(9+m<n&&n<28-m)||(28+m<n&&n<39)){
    System.out.print("#");
    }
    if((9-m<=n&&n<=9+m)||(28-m<=n&&n<=28+m)){
    System.out.print("*");
    }
    if(n==39){
    System.out.println("");
    }
    }
    }
      

  12.   


    package test;public class Rectangular {


    public static void main(String[] args){
    for(int i = 0;i<10;i++){
    for(int j = 0;j<38;j++){
    if(j<9-i)
    System.out.print("#");
    if(8-i<j&&j<10+i)
    System.out.print("*");
    if(9+i<j&&j<28-i)
    System.out.print("#");
    if(27-i<j&&j<29+i)
    System.out.print("*");
    if(28+i<j&&j<38)
    System.out.print("#");
    }
    System.out.println();
    }
    }}前面好多高手啊,呵呵,我做了一个,就是比较简单,献献丑!
      

  13.   

    明显的是考逻辑嘛 
     用 println()去拼的是猪头!
      

  14.   

    public class PrintShape {

    private int total = 38;
    private int line = 10;

    public void print(char ch,int times){
    for(int i=0;i<times;i++){
    System.out.print(ch);
    }
    }

    public void shape(){
    for(int i=1; i<=10; i++){
    print('#', line - i);
    print('*',(total - 4*(line-i)) / 2);
    print('#', 2*(line - i));
    print('*',(total - 4*(line-i)) / 2);
    print('#', line - i);
    System.out.println();
    }
    } public static void main(String[] args) {
    PrintShape shape = new PrintShape();
    shape.shape();
    }
    }