A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 王震阳老师   /  2014-7-4 16:55  /  15955 人查看  /  283 人回复  /   2 人收藏 转载请遵从CC协议 禁止商业使用本文

来看看,领题!
回复 使用道具 举报
已传,老师请验收!

3期.zip

6.93 KB, 阅读权限: 150, 下载次数: 2

评分

参与人数 1技术分 +1 收起 理由
王震阳老师 + 1 赞一个!

查看全部评分

回复 使用道具 举报
陈宁 发表于 2014-12-8 09:09
已传,老师请验收!
  1. package day13;
  2. import java.util.Scanner;
  3. /*
  4.      *
  5.     ***
  6.    *****
  7.   *******
  8. *********
  9. ***********
  10. *********
  11.   *******
  12.    *****
  13.     ***
  14.      *
  15. */
  16. public class TheThirdExam {
  17.         public static void main(String[] args) {
  18.                 Scanner s=new Scanner(System.in);
  19.                 System.out.println("请输入一个数:");
  20.                 int input=s.nextInt();
  21.                
  22.                 //正三角
  23.                 int count=0;
  24.                 for(int a=1;a<=input;a++){
  25.                         for(int b=0;b<=input+count;b++){
  26.                                 if(b<=input-a){
  27.                                         System.out.print(" ");
  28.                                 }else{
  29.                                         System.out.print("*");
  30.                                 }
  31.                         }
  32.                         System.out.println();
  33.                         count++;
  34.                 }
  35.                
  36.                 //倒三角
  37.                 for(int a=1;a<input;a++){
  38.                         for(int b=1;b<input+count;b++){
  39.                                 if(b<=a+1){
  40.                                         System.out.print(" ");
  41.                                 }else{
  42.                                         System.out.print("*");
  43.                                 }       
  44.                         }
  45.                         System.out.println();
  46.                         count--;
  47.                 }
  48.         }

  49. }
复制代码

不错。
回复 使用道具 举报
老师,我又来领题了:)
回复 使用道具 举报
佛说 发表于 2014-12-8 20:28
老师,我又来领题了

好的,老面孔了。
回复 使用道具 举报
看看题目
回复 使用道具 举报

这题用二维数组,挺好玩的。

HeimaDemo.rar

828 Bytes, 下载次数: 162

评分

参与人数 1技术分 +1 收起 理由
王震阳老师 + 1 赞一个!

查看全部评分

回复 使用道具 举报
wangzheng406 发表于 2014-12-10 02:04
这题用二维数组,挺好玩的。

不错。
  1. import java.io.*;

  2. class HeimaDemo{
  3.         public static void main (String []args) throws IOException{
  4.                 BufferedReader br = new BufferedReader(
  5.                                                                 new InputStreamReader(System.in) );
  6.                 int x = 0 ;
  7.                 System.out.println("请输入一个大于2的数字,初始化图形");
  8.                 while(true){
  9.                         String line = br.readLine();
  10.                          x = Integer.parseInt(line);
  11.                                 if(x>2){
  12.                                         break;
  13.                                 }
  14.                                 System.out.println("请输入一个大于2的数字!");
  15.                 }
  16.                 char [][]arr = ready(x);
  17.                 print(arr);
  18.                 int y = 0 ;
  19.                 System.out.println("请输入一个大于0的数字,图形将会翻转。输入exit退出。");
  20.                 while(true){
  21.                         String line = br.readLine();
  22.                           boolean b=line.matches("[0-9]*");
  23.                           if(b) {
  24.                                   y=Integer.parseInt(line);

  25.                                                 for(y=y%4;y>0 ;y--){
  26.                                                         arr = spin(arr);
  27.                                                 }
  28.                                                 print(arr);

  29.                                         System.out.println("请输入一个大于0的数字!输入exit退出");         
  30.                           }
  31.                           else{
  32.                                   if(line.equals("exit")){
  33.                                           break;
  34.                                   }
  35.                                   else
  36.                                   System.out.println("输入的数字有误!");
  37.                           }

  38.                 }
  39.         }
  40.        
  41.         public static char[][] ready(int x){
  42.                 char [][]arr = new char[x][x];
  43.                 for( int n = 0;n < x ; n++ ){
  44.                         for( int m = 0;m < x ; m++ ){

  45.                                 if(n+m>=(x-1)/2 && n+m<= x/2+x-1 && m-n<=x/2 && n-m<=x/2 ){
  46.                                         arr[n][m] = '*';
  47.                                 }
  48.                         }
  49.                 }
  50.                 arr[0][(x-1)/2-1] = 'O';
  51.                 arr[0][x/2+1] = 'O';
  52.                 return arr;
  53.         }
  54.        
  55.         public static void print(char[][] arr){
  56.                 int x =arr.length;
  57.                 for( int n = 0;n < x ; n++ ){
  58.                         for( int m = 0;m < x ; m++ ){
  59.                                 System.out.print(arr[n][m]);
  60.                         }
  61.                         System.out.println();
  62.                 }
  63.         }       
  64.        
  65.         public static char[][] spin(char[][] arr){
  66.                 int x =arr.length;
  67.                
  68.                 char[][] temp = new char[x][x];
  69.                 for( int n = 0;n < x ; n++ ){
  70.                         for( int m = 0;m < x ; m++ ){
  71.                                 temp[m][x-n-1] = arr[n][m] ;
  72.                         }
  73.                 }
  74.                 return temp ;
  75.         }       
  76. }
复制代码
回复 使用道具 举报
遵守规矩,安静答题:lol
回复 使用道具 举报
wangzheng406 发表于 2014-12-10 02:04
这题用二维数组,挺好玩的。

不错:
  1. import java.io.*;

  2. class HeimaDemo{
  3.         public static void main (String []args) throws IOException{
  4.                 BufferedReader br = new BufferedReader(
  5.                                                                 new InputStreamReader(System.in) );
  6.                 int x = 0 ;
  7.                 System.out.println("请输入一个大于2的数字,初始化图形");
  8.                 while(true){
  9.                         String line = br.readLine();
  10.                          x = Integer.parseInt(line);
  11.                                 if(x>2){
  12.                                         break;
  13.                                 }
  14.                                 System.out.println("请输入一个大于2的数字!");
  15.                 }
  16.                 char [][]arr = ready(x);
  17.                 print(arr);
  18.                 int y = 0 ;
  19.                 System.out.println("请输入一个大于0的数字,图形将会翻转。输入exit退出。");
  20.                 while(true){
  21.                         String line = br.readLine();
  22.                           boolean b=line.matches("[0-9]*");
  23.                           if(b) {
  24.                                   y=Integer.parseInt(line);

  25.                                                 for(y=y%4;y>0 ;y--){
  26.                                                         arr = spin(arr);
  27.                                                 }
  28.                                                 print(arr);

  29.                                         System.out.println("请输入一个大于0的数字!输入exit退出");         
  30.                           }
  31.                           else{
  32.                                   if(line.equals("exit")){
  33.                                           break;
  34.                                   }
  35.                                   else
  36.                                   System.out.println("输入的数字有误!");
  37.                           }

  38.                 }
  39.         }
  40.        
  41.         public static char[][] ready(int x){
  42.                 char [][]arr = new char[x][x];
  43.                 for( int n = 0;n < x ; n++ ){
  44.                         for( int m = 0;m < x ; m++ ){

  45.                                 if(n+m>=(x-1)/2 && n+m<= x/2+x-1 && m-n<=x/2 && n-m<=x/2 ){
  46.                                         arr[n][m] = '*';
  47.                                 }
  48.                         }
  49.                 }
  50.                 arr[0][(x-1)/2-1] = 'O';
  51.                 arr[0][x/2+1] = 'O';
  52.                 return arr;
  53.         }
  54.        
  55.         public static void print(char[][] arr){
  56.                 int x =arr.length;
  57.                 for( int n = 0;n < x ; n++ ){
  58.                         for( int m = 0;m < x ; m++ ){
  59.                                 System.out.print(arr[n][m]);
  60.                         }
  61.                         System.out.println();
  62.                 }
  63.         }       
  64.        
  65.         public static char[][] spin(char[][] arr){
  66.                 int x =arr.length;
  67.                
  68.                 char[][] temp = new char[x][x];
  69.                 for( int n = 0;n < x ; n++ ){
  70.                         for( int m = 0;m < x ; m++ ){
  71.                                 temp[m][x-n-1] = arr[n][m] ;
  72.                         }
  73.                 }
  74.                 return temp ;
  75.         }       
  76. }
复制代码
回复 使用道具 举报
本帖最后由 0_TNT_0 于 2014-12-14 01:11 编辑

老师题目答完了,请阅,谢谢!!!

DiamondDemo.zip

1.55 KB, 下载次数: 157

评分

参与人数 1技术分 +1 收起 理由
王震阳老师 + 1 赞一个!

查看全部评分

回复 使用道具 举报
领题。。。。。
回复 使用道具 举报
领题                          
回复 使用道具 举报
领题    。。。。。。。。。。。。。。。。。。。                     
回复 使用道具 举报
领题来了!
回复 使用道具 举报
阳哥请查收!





Test3.zip (1.02 KB, 下载次数: 1)



评分

参与人数 1技术分 +1 收起 理由
王震阳老师 + 1 赞一个!

查看全部评分

回复 使用道具 举报
领题,试试看
回复 使用道具 举报
回帖领题
回复 使用道具 举报
0_TNT_0 发表于 2014-12-13 23:30
老师题目答完了,请阅,谢谢!!!

再次再提交答案一定把截图也提交了。
回复 使用道具 举报
有阳哥的鼓励,我会越挫越勇的!加油!!!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马