package com.edu;
import java.util.Scanner;
public class Sum {
public static void main(String[] args) {
int count = 0;
while (0<1) {
Scanner s = new Scanner(System.in);
System.out.println("请输入字符串:");
String str = null;
str = s.next();
if (!"q".equals(str)) {
count++;
} else {
break;
}
}
System.out.println("共输入" + count + "行");
}
}
java循环输入并计算输入的字符串个数,按q停止循环
最新推荐文章于 2024-07-01 02:56:50 发布