java 将一个数组逆序输出的方法
作者:哦_也好 时间:2023-05-09 09:29:01
题目:
将一个数组逆序输出。
代码:
import java.util.*;
public class lianxi31 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a[] = new int[20];
System.out.println("请输入多个正整数(输入-1表示结束):");
int i=0,j;
do{
a[i]=s.nextInt();
i++;
}while (a[i-1]!=-1);
System.out.println("你输入的数组为:");
for( j=0; j<i-1; j++) {
System.out.print(a[j]+" ");
}
System.out.println("\n数组逆序输出为:");
for( j=i-2; j>=0; j=j-1) {
System.out.print(a[j]+" ");
}
}
}
来源:https://blog.csdn.net/iamdingruihaha/article/details/74643583
标签:java,数组,逆序,输出
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android中new Notification创建实例的最佳方法
2022-03-19 15:52:25
PageHelper引发的幽灵数据问题解析
2022-08-15 22:33:13
![](https://img.aspxhome.com/file/2023/7/101987_0s.png)
Android 仿淘宝、京东商品详情页向上拖动查看图文详情控件DEMO详解
2022-01-17 12:21:18
![](https://img.aspxhome.com/file/2023/7/138077_0s.gif)
带你详细了解Java值传递和引用传递
2023-02-19 08:42:26
![](https://img.aspxhome.com/file/2023/9/61009_0s.jpg)
C#配置文件操作类分享
2022-09-28 11:12:05
Java Date时间类型的操作实现
2023-11-25 06:44:31
![](https://img.aspxhome.com/file/2023/0/59370_0s.jpg)
如何在springBoot下搭建日志框架
2021-07-01 03:41:44
![](https://img.aspxhome.com/file/2023/5/89495_0s.png)
Unity3D选择本地图片并加载
2023-11-20 09:25:05
![](https://img.aspxhome.com/file/2023/5/96315_0s.png)
SpringBoot自动配置原理分析
2022-03-02 17:42:51
![](https://img.aspxhome.com/file/2023/8/62058_0s.webp)
Spring MVC请求参数的深入解析
2021-11-26 22:55:25
![](https://img.aspxhome.com/file/2023/3/61573_0s.png)
Android中Toolbar随着ScrollView滑动透明度渐变效果实现
2023-10-08 21:06:50
Android APK反编译图文教程
2022-02-04 01:46:46
![](https://img.aspxhome.com/file/2023/9/139059_0s.jpg)
Java基于Dijkstra算法实现校园导游程序
2021-10-15 15:38:18
![](https://img.aspxhome.com/file/2023/4/104014_0s.jpg)
Android 中在有序广播中添加自定义权限的实例
2021-08-10 05:09:35
c#使用linq把多列的List转化为只有指定列的List
2022-07-04 12:00:31
![](https://img.aspxhome.com/file/2023/2/82112_0s.png)
timespan使用方法详解
2022-01-19 07:04:50
Spring源码解密之自定义标签与解析
2023-11-25 01:11:34
![](https://img.aspxhome.com/file/2023/2/60112_0s.png)
SpringBoot ResponseBody返回值处理的实现
2023-06-29 23:18:43
java中的JsonSerializer用法,前后端单位转换必备
2022-05-01 07:58:48
![](https://img.aspxhome.com/file/2023/4/64904_0s.jpg)
基于C# winform实现图片上传功能的方法
2022-09-12 18:18:14