zoukankan      html  css  js  c++  java
  • 数组练习

    package day2;
    //输出格式:【word1#word2#word3】;//
    public class d2 {
    public static void main(String[] args) {
    int []array={1,2,3};
    String str=form(array);
    System.out.println(str);
    }
    public static String form(int []a)
    {
    String str="[";
    for(int i=0;i<a.length;i++)
    {
    if(i==a.length-1)
    {
    str=str+"word"+a[i]+"]";
    }
    else
    {
    str=str+"word"+a[i]+"#";
    }
    }
    return str;
    }
    }
    package day2;
    import java.util.Scanner;
    public class d3 {
    public static void main(String[] args) {
    Scanner sr = new Scanner(System.in);
    System.out.println("请输入字符串:");
    String str = sr.next();
    int countu = 0;
    int countl = 0;
    int countn = 0;
    int counto = 0;
    char[] arr = str.toCharArray();
    for (int i = 0; i < arr.length; i++) {
    char ch = arr[i];
    if (ch >= 'A' && ch <= 'Z') {
    countu++;
    } else {
    if (ch >= 'a' && ch <= 'z') {
    countl++;
    } else {
    if (ch >= '0' && ch <= '9') {
    countn++;
    } else {
    counto++;
    }
    }
    }
    }
    System.out.println(countu);
    System.out.println(countl);
    System.out.println(countn);
    System.out.println(counto);
    }
    }
  • 相关阅读:
    如何在百度文库里面免费下载东西
    CompareTo
    MySql常用日期函数(转载)
    Oracle之ORDER BY
    Spring之Ioc
    在使用与测绘有关软件中的困难
    HDOJ_1008_Elevator
    HDOJ_1005_Number Sequence
    HDOJ_1004_Let the Balloon Rise
    HDOJ_1003_MaxSum
  • 原文地址:https://www.cnblogs.com/huaobin/p/13366801.html
Copyright © 2011-2022 走看看