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);
    }
    }
  • 相关阅读:
    背景透明,文字不透明
    判断数组类型
    前端工作流程自动化——Grunt/Gulp 自动化
    tools安装
    总结
    CSS Hack
    getBoundingClientRect()兼容性处理
    Math.random获得随机数
    spring RestTemplate 工程导入
    系统架构演变
  • 原文地址:https://www.cnblogs.com/huaobin/p/13366801.html
Copyright © 2011-2022 走看看