zoukankan      html  css  js  c++  java
  • Lesson_4 作业_2 数组构建扑克牌

    2013-01-14

     1 /******************************题目描述***********************************
     2 *     用数组构建一副扑克牌52张(花色和数值),并输出到屏幕。
     3 *     提示:可以用二维数组来实现
     4 ********************************解题思路***********************************
     5 *
     6 *     用一个poker[4][14]来存储信息,每行的第一个位置存放花色,其他的放数字
     7 *
     8 ********************************注释***************************************
     9 *                       2012-1-15 by CocoonFan
    10 ****************************************************************************/
    11 
    12 
    13 public class 数组构建扑克牌{
    14     public static void main(String [] args){
    15         /*for(int i = 1; i <= 255; i++){
    16             System.out.print( (char)i +"->" + i + " ");
    17         }*/
    18 
    19         String []pokerStr = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
    20         String []pokerType = {"黑桃","红桃","方块","梅花"};
    21         String poker[][] = new String[4][14];
    22         for(int i = 0; i < 4; i++){
    23             poker[i][0] = pokerType[i];
    24             for(int j = 0; j< 14; j++){
    25                 if(j == 0){
    26                     System.out.print(poker[i][j] + " ");
    27                     continue;
    28                 }
    29                 poker[i][j] = pokerStr[j-1];
    30                 System.out.print(poker[i][j] + " ");
    31             }
    32             System.out.println();
    33         }
    34     }
    35 }

    运行结果:

      

      
     

  • 相关阅读:
    函数式宏定义与普通函数
    linux之sort用法
    HDU 4390 Number Sequence 容斥原理
    HDU 4407 Sum 容斥原理
    HDU 4059 The Boss on Mars 容斥原理
    UVA12653 Buses
    UVA 12651 Triangles
    UVA 10892
    HDU 4292 Food
    HDU 4288 Coder
  • 原文地址:https://www.cnblogs.com/CocoonFan/p/2861659.html
Copyright © 2011-2022 走看看