- 5
- 0
- 约1.02万字
- 约 26页
- 2017-06-05 发布于河南
- 举报
Res_java练习题讲解(国外英文资料)
Res_java练习题讲解
9 weeks experiment:
1. The program fills in and does not change the statements associated with the input output.
Continuously enter a number of characters that end with # (no Spaces).
Statistics and output the length of each string.
The output of the output is system.out.println (len);
Example: the parenthesis is the explanation
Input:
Hello_12 # ABC + 0 # (serial2 characters hello_12 and ABC + 0)
Output:
The length of hello_12 is 8.
The length of ABC plus 0 is 5.
Code:
Import the Java. Util. Scanner;
Public class Test60021 {
Public static void main (String [] args)
@ SuppressWarnings ( unused )
Int len, count, I, k;
@ SuppressWarnings ( unused )
Char ch;
String STR.
Scanner in = new Scanner.
STR = in nextLine ();
* * * * * * * * * * *
Len = 0; Count = 0;
For (I = 0; I STR. Length (); I + +)
{
If (STR. CharAt (I)! = #)
{
Len++;
}
The else {
System. The out. Println (len);
Len = 0;
}
}
}
}
2. The program fills in and does not change the statements associated with the input output.
Enter a character, ch, first. Then enter a positive integer n (0 n 10), and do the following operations n times:
Enter a string, find the character (ch) in the string, and output if found
The last location of the character in the string (starting at 0); Otherwise output Not Found.
Example: the parenthesis is the explanation
Input:
M (enter a character)
3 (enter 3 lines of string)
moon
programming
1234
Output:
0 (m in moon, where the last position is 0)
7 (m in programming)
Not Found ( 1234 )
Code:
Import the Java. Util. Scanner;
Public class Test60023 {
Public static void main (String [] args)
Int index, I, n, j.
Char ch;
String STR.
Scanner in = new Scanner.
()
(in).nextline ()).charat (0) - 0;
For (I = 1; I = n; I + +) {
STR = in nextLine ();
The index = 1;
For (j = 0; j STR. Length (); j + +) {
If (STR. CharAt (j) = = ch) {
The index = j;
}
}
If (index = 0) system.out.println (index);
The other System is Not Found.
}
}
}
3. The program fills in and does not change the
您可能关注的文档
- 57种方法寻注进点(国外英文资料).doc
- 5二级vf考试笔试(国外英文资料).doc
- 5购置行动(国外英文资料).doc
- 60年:那些祛除和更生的词语(国外英文资料).doc
- 6级测验词汇@-@(国外英文资料).doc
- 71种网络故障及解决办法一览(国外英文资料).doc
- 7年纪英语单词表(国外英文资料).doc
- 40条最易搞错的生活常识(国外英文资料).doc
- 7月2日 缺少层次的潜熟悉(国外英文资料).doc
- 8.语病剖析(国外英文资料).doc
- 2025年北京市门头沟区中考一模英语试题.docx
- 2025年北京市门头沟区中考二模英语试题.docx
- 2025年北京市丰台区中考二模英语试题.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 解析卷.docx
- 2025年中考英语考前冲刺模拟卷 (北京专用) 原卷.docx
- 2025年肩颈按摩仪行业社媒趋势数据分析.docx
- 2025年人身险行业信用回顾与2026年展望.docx
- 合同法买卖合同培训课件.ppt
- 2025年全球食物系统与SDG研究报告-食物供给、食者健康、生态平衡的整体治理.docx
- 2025下半年四川乐山市川投峨眉铁合金(集团)有限责任公司对考前自测高频考点模拟试题最新.docx
原创力文档

文档评论(0)