首页 > 20209/9中国电信云计算笔试
头像
擎宇要努力努力再努力
编辑于 2020-09-09 22:45
+ 关注

20209/9中国电信云计算笔试

一、15个单选、5个多选
二、3个编程
//1、输出第N个丑数
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();

int two = 0;
int three =0;
int five = 0;
ArrayList<Integer> ugly = new ArrayList<> ();
ugly.add(1);
for(int i = 0; i < a-1; i++ ){
while(true){
if(ugly.get(two) * 2 > ugly.get(ugly.size()-1)){
break;
}
two++;
}
while(true){
if(ugly.get(three) * 3 > ugly.get(ugly.size()-1)){
break;
}
three++;
}
while(true){
if(ugly.get(five) * 5 > ugly.get(ugly.size()-1)){
break;
}
five++;
}
int m = Math.min(ugly.get(two)*2,ugly.get(three)*3);
int n = Math.min(m,ugly.get(five)*5);
ugly.add(n);
}
System.out.println(ugly.get(a-1));

}
}

//2 a、b、c、d为0-9的正整数,abcd+bcda=8888,输出满足要求的所有a、b、c、d
输出格式为  a1 b1 c1 d1
a2 b2 c2 d2
………………
public class Main {
public static void main(String[] args) {
int a,b,c,d;
for(int i =0; i < 8888; i++ ){
a = i/1000;
b = (i-a*1000)/100;
c = (i-a*1000-b*100)/10;
d = i-a*1000-b*100-c*10;

if((i+b*1000+c*100+d*10+a) == 8888){

System.out.println(a+" "+b+" "+c+" "+d);
}
}
}
}


//3求不相邻的最大和

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
String s[] = str.split(",");
int len = s.length;
int [] num = new int[len];
for(int i = 0; i < len; i++){
num [i]= Integer.parseInt(s[i]);
}
int [] sum = new int[len+1];
sum[0] = 0;
sum [1] = num[0];
for(int i =2; i <=len; i++){
sum[i] = Math.max(sum[i-1],sum[i-2]+num[i-1]);
}
System.out.println(sum[len]);
}
}

全部评论

(1) 回帖
加载中...
话题 回帖

相关热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐