当前位置: 首页 > news >正文

Java强训day13(选择题编程题)

选择题
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

编程题
题目1
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String s = sc.nextLine();char[] c = s.toCharArray();int i = 0;int t = 0;while (i < c.length) {if (c[i] != '\"') {while (i < c.length && c[i] != ' ') {
//                  System.out.print(c[i]);i++;}i++;
//              System.out.println();t++;} else if (c[i] == '\"') {i++;while (i < c.length && c[i] != '\"') {
//                  System.out.print(c[i]);i++;}i += 2;
//              System.out.println();t++;}}System.out.println(t);i = 0;while (i < c.length) {if (c[i] != '\"') {while (i < c.length && c[i] != ' ') {System.out.print(c[i]);i++;}i++;System.out.println();t++;} else if (c[i] == '\"') {i++;while (i < c.length && c[i] != '\"') {System.out.print(c[i]);i++;}i += 2;System.out.println();t++;}}sc.close();}
}
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String s = sc.nextLine();char[] c = s.toCharArray();int i = 0;int t = 0;StringBuffer sb = new StringBuffer();while(i<c.length) {if(c[i]!='\"') {while(i<c.length && c[i]!=' ') {
//					System.out.print(c[i]);sb.append(c[i]);i++;}i++;
//				System.out.println();sb.append("1");t++;}else if(c[i] == '\"') {i++;while(i<c.length && c[i] != '\"') {
//					System.out.print(c[i]);sb.append(c[i]);i++;}i+=2;
//				System.out.println();sb.append("1");t++;}			}System.out.println(t);for(i=0;i<sb.length();i++) {if(sb.charAt(i)!='1')System.out.print(sb.charAt(i));elseSystem.out.println();				}sc.close();}
}
http://www.lryc.cn/news/291327.html

相关文章:

  • 搭建WebGL开发环境
  • 学习嵌入式第十五天之结构体
  • 【HDFS】一天一个RPC系列--updateBlockForPipeline
  • 测试面试题(0101设计测试用例关键)
  • C++ 数论相关题目:高斯消元解异或线性方程组
  • 嵌入式学习第十四天
  • 氢气泄漏检测仪使用方法:守护安全,从细节开始
  • 【前端web入门第二天】01 html语法实现列表与表格_合并单元格
  • 推荐系统|排序_MMOE
  • Redis拒绝连接的原因与解决方式
  • Neo4j在java中的使用
  • 故障诊断 | 一文解决,CNN卷积神经网络故障诊断(Matlab)
  • uniapp-app使用富文本编辑器editor
  • 20240131 大模型快讯
  • MySQL原理(二)存储引擎(2)MyISAM
  • P1088 [NOIP2004 普及组] 火星人题解
  • Python面向对象编程:探索代码的结构之美
  • Java基于SpringBoot+Vue的电影影城管理系统,附源码,文档
  • 【学网攻】 第(14)节 -- 动态路由(EIGRP)
  • 【Linux】多线程(线程概念+线程控制)
  • 【昕宝爸爸小模块】深入浅出详解之常见的语法糖
  • 低代码
  • 2024/1/30 备战蓝桥杯 3-1 栈
  • qt setStyleSheet 设置多个属性{}之间用空格间隔
  • 【Node.js基础】Node.js的介绍与安装
  • 树和二叉树基础
  • 第十四届蓝桥杯大赛软件赛省赛(C/C++ 大学B组)题解
  • 【计算机网络】网络的网络
  • SQL Server 函数参考手册
  • NTP时间同步服务器@客户端时钟同步设置