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);
    }
    }
  • 相关阅读:
    git reset 用法
    print、println、printf的区别
    GoLang(2)
    GoLang
    OpenCV 图像叠加or图像混合加权实现
    openpyxl
    EJB 的理解
    inotify-tool实时监控服务器文件状态变化 学习总结
    使用docker 安装maven私服 nexus
    dockerfile 学习总结
  • 原文地址:https://www.cnblogs.com/huaobin/p/13366801.html
Copyright © 2011-2022 走看看