用javac语言输出水仙花数10到1之间的数

程序计算1到10之间所有奇数之和,偶数之和,输出两个和的结果_c语言吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:250,922贴子:
程序计算1到10之间所有奇数之和,偶数之和,输出两个和的结果收藏
快试试吧,可以对自己使用挽尊卡咯~◆◆
用。
自己编去。
别指望别人帮你把答案全部写出来。
这种题用for做很傻,笔算出结果后直接输出就可以了。
登录百度帐号我的游戏推荐游戏
后查看最近玩过的游戏
使用签名档&&
为兴趣而生,贴吧更懂你。或一道Java面试题 读取一篇英文文章,输出其中出现单词的次数最多的5个,写java函数
package com.test.
import java.io.BufferedR
import java.io.FileR
import java.io.IOE
import java.util.ArrayL
import java.util.C
import java.util.HashM
import java.util.L
import java.util.M
import java.util.Map.E
import java.util.regex.M
import java.util.regex.P
public class TesWordCount {
/**解题思路
1.先去取文件的问内容
2.对读取文件中的内容进行正则匹配【a-zA-Z】
3.用Map保存 单词 和出现的次数
4.自定义Comparator排序
5.把map中内容放到list中
6.对list进行Collections.sort() 进行自定义排序
7。输出排序后的内容
* @param args
* @throws IOException
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
@SuppressWarnings("resource")
BufferedReader buffer=new BufferedReader(new FileReader("d:/c.txt"));
StringBuffer sb=new StringBuffer();
String str=
while((str=buffer.readLine())!=null){
sb.append(str);
buffer.close();
Pattern pile("[a-zA-Z]+");
Matcher matcher=pattern.matcher(sb.toString());
Map map=new HashMap();
String word="";
while(matcher.find()){
word=matcher.group();
//System.out.println("sr="+word);
if(map.containsKey(word)){
count=map.get(word);
map.put(word, count+1);
map.put(word, 1);
List<Map.Entry> list=new ArrayList<Map.Entry>(map.entrySet());
Collections.sort(list,new MyComparable());
int last=list.size()-1;
for(int i=i>last-5;i--){
System.out.println("key="+list.get(i).getKey()+" value="+list.get(i).getValue());
class MyComparable implements Comparator<Map.Entry>{
public int compare(Entry o1, Entry o2) {
// TODO Auto-generated method stub
return o1.getValue().compareTo(o2.getValue());
您对本文章有什么意见或着疑问吗?请到您的关注和建议是我们前行的参考和动力&&
您的浏览器不支持嵌入式框架,或者当前配置为不显示嵌入式框架。jdk 编写java程序,接受用户输入的1~12之间的整数,若不符合条件则重新输入,利用switch语句 输出对应月份_百度知道
jdk 编写java程序,接受用户输入的1~12之间的整数,若不符合条件则重新输入,利用switch语句 输出对应月份
jdk 编写java程序,接受用户输入的1~12之间的整数,若不符合条件则重新输入,利用switch语句 输出对应月份的天数 要加上详细的注释
提问者采纳
import java.util.*;public class month { public static void main(String[] args) {//定义用户输入的数字
Scanner scanner=new Scanner(System.in);
boolean flag=//定义标志,如果用户选择退出,则flag=false
while(flag){
System.out.print(&请输入(1--12)之间的一个整形的数据(输入0结束):&);//打印提示信息
month=scanner.nextInt();//接受键盘的输入
switch(month){
case 0:System.out.println(&您已退出&);flag=
case 1:System.out.println(&一月31天&);
case 2:System.out.println(&二月28天或29天&);
case 3:System.out.println(&三月31天&);
case 4:System.out.println(&四月30天&);
case 5:System.out.println(&五月31天&);
case 6:System.out.println(&六月30天&);
case 7:System.out.println(&七月31天&);
case 8:System.out.println(&八月31天&);
case 9:System.out.println(&九月30天&);
case 10:System.out.println(&十月31天&);
case 11:System.out.println(&十一月30天&);
case 12:System.out.println(&十二月31天&);
default :System.out.println(&输入错误,请重新输入&);
提问者评价
其他类似问题
按默认排序
其他2条回答
public class AAA { public void getDay(int month) {
if (month &= 12 && month &= 1) {
switch(month){
//4,6,9,11小月返回30天
System.out.println(30+&天&);
//二月比较特殊要分闰年和非闰年考虑
System.out.println(&请输入年份:&);
Scanner input=new Scanner(System.in);
int year=input.nextInt();
//如果是闰年29天
if(year%4==0&&year%100!=0||year%400==0){
System.out.println(29+&天&);
//不是闰年28天
System.out.println(28+&天&);
//默认为大月返回31天
System.out.println(31+&天&);
System.out.println(&月份输入不正确,应为1-12之间的数值&); }}
jdk的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁任意输入一个整数(小于10位),求它的位数.(java语言)_百度知道
任意输入一个整数(小于10位),求它的位数.(java语言)
提问者采纳
将数字转换为字符串,然后利用length方法就可以——public class Tester { public static void main(String[] args) {
System.out.println(count()); }
public static int count(long num) {
return String.valueOf(num).length(); }}
提问者评价
谢了!!!
其他类似问题
按默认排序
其他2条回答
import java.io.*;public class test{
public static void main(String args[]) throws IOException{
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(reader);
String text=input.readLline();
System.out.println(&请输入一个整数(小于十位):&);
if(text.length()&=10)
System.out.println(&这个整数超过十位&);
System.out.println(&这个整数有:&+ text.length()+&位&); }}
import java.util.Spublic class size { public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println(&请输入一个十位一下的整数:&);
int num = s.nextInt();
String Snum = String.valueOf(num);
System.out.println(Snum.length()); }}
java语言的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 java输出16进制 的文章

 

随机推荐