工具类_参考答案(最新整理)_第1页
工具类_参考答案(最新整理)_第2页
工具类_参考答案(最新整理)_第3页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1、编写一个程序,实现从命令行参数输入两个字符串类型的数值,并计算输出两个数值的和。public class exercise_09_01 public static void main(string args) /读取命令行数据,并进行类型转换int x = integer.parseint(args0);int y = integer.parseint(args1); int z = x+y; system.out.println(z);2、编写一个程序,实现从命令行参数输入一字符串,统计该字符串中字符“e”出现的次数。public class test /* param args*/pu

2、blic static void main(string args) scanner in = new scanner(system.in); string s = in.next();int num = 0;for(int i =0;i s.length();i+)if(s.charat(i)=e) num+;system.out.println(num);3、生成十个 0100 之间的随机数,放到数组中,然后排序输出。public class test public static void num()int a = new int8;for(int i = 0;ia.length;i+)a

3、i = (int)(math.random()*101);arrays.sort(a);for(int i = 0;is.lastindexof(.) system.out.println(邮箱地址中.出现在的前面); return false;for(int i=0;i=a&s.charat(i)=a&s.charat(i)=z) )elsesystem.out.println(用户名里有其他字符);return false;return true;public class test /* param args*/public static void main(string args) /

4、todo auto-generated method stubif(mailtest.testmail() system.out.println(邮箱格式合法);elsesystem.out.println(邮箱格式不合法);6、分别在控制台输入字符串和子字符串,并计算字符串中子字符串出现的次数。public class test /* param args*/public static void main(string args) / todo auto-generated method stub scanner in = new scanner(system.in); string s =

5、 in.next();string a = in.next();int num = 0;/i是循環的次數for(int i = 0;is.length()-a.length();i=s.indexof(a, i)+1)if(s.indexof(a, i)!=-1) num+;system.out.println(num);7、有一个字符串,其中包含中文字符、英文字符和数字字符,请统计和打印出各个字符的个数。public class test /* param args*/public static void main(string args) / todo auto-generated met

6、hod stub scanner in = new scanner(system.in); string s = in.next();int num=0,eng=0,china=0;for(int i =0;i=0&s.charat(i)=a&s.charat(i)=a&s.charat( i)=z)eng+;else if(19968 = s.charat(i) & s.charat(i) 40623) china+;system.out.println(数字是:+num); system.out.println(英文是:+eng); system.out.println(中文是:+chin

7、a);8 有一种数叫回文数,正读和反读都一样,如 12321 便是一个回文数。编写一个程序,从命令行得到一个整数,判断该数是不是回文数。public class test /* param args*/public static void main(string args) / todo auto-generated method stubif(foo()system.out.println(是回数);elsesystem.out.println(不是回数);public static boolean foo()scanner in = new scanner(system.in); stri

8、ng s = in.next();int j = s.length()-1;for(int i=0;is.length()/2;i+)if(s.charat(i)!=s.charat(j)return false;j-;return true;“”“”at the end, xiao bian gives you a passage. minand once said, people who learn to learn are very happy people. in every wonderful life, learning is an eternal theme. as a prof

9、essional clerical and teaching position, i understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning can achieve better self. only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the mar

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论