- 博客(7)
- 收藏
- 关注
原创 计算行程中的时间
输入2个整数time 1和time2,表示火车的出发时间和到达时间,计算并输出旅途时间。有效的时间范围是0000到2359,不需要考虑出发时间晚于到达时间的情况。例:括号内是说明输入712 1411 (出发时间是7: 10, 到达时间是14:11 )输出The train journey time is 6 hrs 59 mins代码:import java.util.Scanne...
2020-02-25 13:45:44 885
原创 大小写字母转换
输入一个大写英文字母,输出相应的小写字母。例:输入G,输出g代码:import java.io.*;public class T20006 {public static void main(String[] args) throws I0Exception{char ch;ch = (char) System.in.read();ch= (char) (ch + 32); /以A...
2020-02-25 13:36:22 266
原创 求平方根
输入1个实数x,计算并输出其平方根。例:输入1.21输出The squqre root of 1.21 is 1.1代码:import java.io.;import java.util.Scanner;public class Test {public static void main(String args[]) {double x, root;Scanner in =...
2020-02-25 13:31:32 299
原创 屏幕上显示网格
在屏幕上显示如下网格。±–±--+| | || | |±–±--+import java.io.;public class Test 10002 {public static void main(String args[]) {/-------------------*/System.out.println(“±–±--+”);System. out.println(“I |I...
2020-02-25 13:26:03 1073
原创 用Python语言求水仙花数
代码:y = 100a = int( input( “百位” ) )b = int( input( “十位” ) )c = int( input( “个位” ) )while (y <= 999) :a = y // 100b = y // 10 % 10c = y % 10if a * a * a + b * b * b + c * c * c == y :print(...
2020-02-17 16:27:23 1488
原创 Python的排序语法
代码:a = [1,2,3,4,5]a.reverse()print(a)a.sort()print(a)注:#排序(sort,reverse)#sort:由小到大#reverse:由大到小#翻转:
2020-02-17 16:25:38 202
原创 Java语言统计100以内的水仙花数
代码:public class Test{public static void main(String[] args){int x=2;int i=2;int count=0;while (x<=100){i=2;while(i<x){if(x%i0){break;}i++;}if(ix){System.out.println(“素数:”+x);coun...
2020-02-17 16:13:32 458
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人