当前位置:网站首页>小王的面试训练任务
小王的面试训练任务
2022-06-27 19:20:00 【continueLR】
目录
XZK-JAVA-支线任务-010102-小王的面试(基础语法)
1. 定义一个整型变量并赋任意五位正整数作为初始值,判断它是不是五位回文数?
2.定义一个整型变量并赋任意五位正整数作为初始值,输出各位数字之和
3. 定义整型变量 a、b,写出将 a、b 两个变量值进行互换的程序 (要求不能使用第三个变量)
4. 请写出一段遵守编码规范的 Hello World 代码
XZK-JAVA-支线任务-010102-小王的面试(基础语法)
1. 定义一个整型变量并赋任意五位正整数作为初始值,判断它是不是五位回文数?
public class Demo {
public static void main(String[] args){
int num = 12321;
int ge = num%10;
int shi = num%100/10;
int qian = num%10000/1000;
int wan = num%100000/10000;
System.out.println(ge);
System.out.println(shi);
System.out.println(qian);
System.out.println(wan);
if(ge==wan&&shi==qian){
System.out.println("该数字是回文数");
}else {
System.out.println("该数字不是回文数");
}
}
}五位回文数,既个=万,十=千;
2.定义一个整型变量并赋任意五位正整数作为初始值,输出各位数字之和
public class Eemo {
public static void main(String[]args){
int num = 12345;
int ge = num%10;
int shi = num%100/10;
int bai = num%1000/100;
int qian = num%10000/1000;
int wan = num%100000/10000;
int sum = ge+shi+bai+qian+wan;
System.out.println(sum);
}
}
3. 定义整型变量 a、b,写出将 a、b 两个变量值进行互换的程序 (要求不能使用第三个变量)
public static void main(String[] args) {
int a=10;
int b=12;
a=a+b;
b=a-b;
a=a-b;
System.out.println(a+"和"+b);
}
}4. 请写出一段遵守编码规范的 Hello World 代码
public class HolleWord {
public static void main(String[] args) {
System.out.println("HolleWord");
}
}
边栏推荐
- AI 绘画极简教程
- 麒麟V10安装字体
- Love math experiment | phase 9 - intelligent health diagnosis using machine learning method
- Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion
- 关于企业数字化的展望(38/100)
- “好声音“连唱10年,星空华文如何唱响港交所?
- SQL必需掌握的100个重要知识点:组合 WHERE 子句
- SQL必需掌握的100个重要知识点:过滤数据
- 白嫖红队goby&POC,叫你如何白嫖?
- Focus! Tips for installing fonts on domestic computers
猜你喜欢

抖音的兴趣电商已经碰到流量天花板?

Kirin V10 installation font

Ceph分布式存储

数据平台调度升级改造 | 从Azkaban 平滑过度到Apache DolphinScheduler 的操作实践

MySQL usage notes 1

Flexible IP network test tool -- x-launch

Wechat applet based service management system for college party members' Home System applet graduation design, Party members, activists, learning, punch in, forum

Zhongang Mining: the largest application field of new energy or fluorite

银河麒麟系统局域网文件共享教程

于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
随机推荐
Cerebral cortex: predicting children's mathematical skills from task state and resting state brain function connections
ARCS模型介绍
Kirin V10 installation font
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
划重点!国产电脑上安装字体小技巧
Focus! Tips for installing fonts on domestic computers
分享一次自己定位 + 解决问题的经历
分享下我是如何做笔记的
oss上传调用的是哪个方法
Data platform scheduling upgrade and transformation | operation practice from Azkaban smooth transition to Apache dolphin scheduler
大促场景下,如何做好网关高可用防护
Codeforces Round #723 (Div. 2)
众昂矿业:新能源或成萤石最大应用领域
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
Use the storcli tool to configure raid. Just collect this article
Experience Navicat premium 16, unlimited reset, 14 day trial method (with source code)
抗洪救灾,共克时艰,城联优品驰援英德捐赠爱心物资
爱数课实验 | 第九期-利用机器学习方法进行健康智能诊断
互联网 35~40 岁的一线研发人员,对于此岗位的核心竞争力是什么?
Love math experiment | phase VI - Financial anti fraud case study