当前位置:网站首页>小王的面试训练任务
小王的面试训练任务
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");
}
}
边栏推荐
- 100 important knowledge points that SQL must master: sorting and retrieving data
- "Good voice" has been singing for 10 years. How can the Chinese language in the starry sky sing well in HKEx?
- 安装gatewayworker之后启动start.php
- 灵活的IP网络测试工具——— X-Launch
- Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
- DO280OpenShift访问控制--security policy和章节实验
- 爱数课实验 | 第六期-金融反欺诈案例研究
- Codeforces Global Round 14
- Experience Navicat premium 16, unlimited reset, 14 day trial method (with source code)
- 展现强劲产品综合实力 ,2022 款林肯飞行家Aviator西南首秀
猜你喜欢
抖音的兴趣电商已经碰到流量天花板?
覆盖接入2w+交通监测设备,EMQ 为深圳市打造交通全要素数字化新引擎
非常全面的DolphinScheduler(海豚调度)安装使用文档
Data platform scheduling upgrade and transformation | operation practice from Azkaban smooth transition to Apache dolphin scheduler
SQL Server for循环用法
Necessary software tools in embedded software development
Kirin V10 installation font
Squid proxy server
Model reasoning acceleration based on tensorrt
Icml2022 | scalable depth Gaussian Markov random field
随机推荐
分享下我是如何做笔记的
教程|fNIRS数据处理工具包Homer2下载与安装
1029 Median
Codeforces Round #721 (Div. 2)
OpenSSL 编程 一:基本概念
Day8 ---- 云资讯项目介绍与创建
Flutter隐藏AppBar的返回按钮
MySQL client tools are recommended. I can't imagine that it is best to use Juran
Is it safe to open an account and buy stocks? Who knows
OpenSSL 编程 二:搭建 CA
Love math experiment | phase 9 - intelligent health diagnosis using machine learning method
众昂矿业:新能源或成萤石最大应用领域
100 important knowledge points that SQL must master: using functions to process data
Zhongang Mining: the largest application field of new energy or fluorite
Share how I take notes
Unity3d button adapts the size according to the text content
AI 绘画极简教程
MySQL Express - day 1 - basic introduction
使用storcli工具配置RAID,收藏这一篇就够了
Ceph分布式存储