当前位置:网站首页>小王的面试训练任务
小王的面试训练任务
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");
}
}
边栏推荐
- VMware vSphere ESXi 7.0安装教程
- Wechat applet based service management system for college party members' Home System applet graduation design, Party members, activists, learning, punch in, forum
- OpenSSL 编程 一:基本概念
- squid代理服务器
- VMware vSphere esxi 7.0 installation tutorial
- Codeforces Round #716 (Div. 2)
- Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
- SQL必需掌握的100个重要知识点:用通配符进行过滤
- Ceph分布式存储
- Release of global Unicorn list in 2021: the full list of 301 Unicorn enterprises in China is coming!
猜你喜欢

At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions

白嫖红队goby&POC,叫你如何白嫖?

一套系统,减轻人流集中地10倍的通行压力

Industry case | see the operation of bank digital transformation from the king of retail

使用storcli工具配置RAID,收藏这一篇就够了

BTC and eth recapture the lost land! Leading the market recovery? Encryption will enter the "ice age"!

通过CE修改器修改大型网络游戏

KDD 2022 | 图“预训练、提示、微调”范式下的图神经网络泛化框架

大促场景下,如何做好网关高可用防护

GoLand永久激活
随机推荐
Love math experiment | phase VI - Financial anti fraud case study
Unity3d button adapts the size according to the text content
Educational Codeforces Round 108 (Rated for Div. 2)
MySQL performance optimization index function, hidden, prefix, hash index usage (2)
爱数课实验 | 第五期-基于机器学习方法的商品评论情感判定
事件相关电位ERP的皮层溯源分析
Release of global Unicorn list in 2021: the full list of 301 Unicorn enterprises in China is coming!
DO280OpenShift访问控制--security policy和章节实验
GFS分布式文件系统
安装gatewayworker之后启动start.php
释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
Can Oracle's CTAs bring constraints and other attributes to the new table?
A set of system to reduce 10 times the traffic pressure in crowded areas
MySQL usage notes 1
Share how I take notes
让马化腾失望了!Web3.0,毫无希望
展现强劲产品综合实力 ,2022 款林肯飞行家Aviator西南首秀
BTC和ETH重新夺回失地!引领市场复苏?加密将步入“冰河时代”!
Animal breeding production virtual simulation teaching system | Sinovel interactive
Codeforces Global Round 14