当前位置:网站首页>小王的面试训练任务
小王的面试训练任务
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");
}
}
边栏推荐
- 银河麒麟系统局域网文件共享教程
- Codeforces Round #719 (Div. 3)
- 释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
- “好声音“连唱10年,星空华文如何唱响港交所?
- GoLand permanently activated
- Animal breeding production virtual simulation teaching system | Sinovel interactive
- # Leetcode 821. Minimum distance of characters (simple)
- 使用storcli工具配置RAID,收藏这一篇就够了
- TypeScript学习
- DO280OpenShift访问控制--security policy和章节实验
猜你喜欢

How to do a good job of gateway high availability protection in the big promotion scenario

JPA踩坑系列之save方法

Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer

DO280OpenShift访问控制--security policy和章节实验

Serveur mandataire SQUID
![Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion](/img/21/9c5f5122270adea9444ff5f2d199ed.jpg)
Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion

基于微信小程序的高校党员之家服务管理系统系统小程序#毕业设计,党员,积极分子,学习,打卡,论坛

分享|智慧环保-生态文明信息化解决方案(附PDF)

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

mysql使用笔记一
随机推荐
分享下我是如何做笔记的
麒麟V10安装字体
划重点!国产电脑上安装字体小技巧
华为伙伴暨开发者大会2022开源时刻全纪录
OpenSSL 编程 一:基本概念
Save method of JPA stepping pit series
GFS分布式文件系统
爱数课实验 | 第九期-利用机器学习方法进行健康智能诊断
100 important knowledge points that SQL must master: sorting and retrieving data
Flood fighting and disaster relief, overcoming difficulties, and City United premium products rushed to the aid of Yingde to donate loving materials
MySQL速成——第一天--基础入门
100 important knowledge points that SQL must master: creating calculation fields
Navicat Premium连接问题--- Host ‘xxxxxxxx‘ is not allowed to connect to this MySQL server
送你12个常用函数公式,用过的都说好
Oracle的CTAS能不能将约束等属性带到新表?
SQL必需掌握的100个重要知识点:检索数据
Modify large online games through CE modifier
“好声音“连唱10年,星空华文如何唱响港交所?
100 important knowledge points that SQL must master: filtering data
Love math experiment | phase 9 - intelligent health diagnosis using machine learning method