Problem D: 数组----逆向存储
来源:互联网 发布:淘宝网店怎样优化 编辑:程序博客网 时间:2024/05/22 02:10
Problem D: 数组----逆向存储
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 465 Solved: 242
[Submit][Status][Web Board]
Description
将10个整数存放到数组后,按逆序重新存放后,再将数组元素从下标0到下标9对应的元素依次输出。
在以下程序基础上完善代码,实现上述功能。只提交begin和end之间的代码。
#include<iostream>
using namespace std;
int main()
{
int array[10];
int i;
for(i=0;i<10;i++)//输入数据元素
cin>>array[i];
//数组元素逆序存储
//---------------begin----------
//---------------end------------
for(i=0;i<10;i++) //输出数组元素
cout<<array[i]<<" ";
return 0;
}
Input
10个整数
Output
逆序存储后数组从下标0到下标9对应的元素值
Sample Input
1 2 3 4 5 6 7 8 9 0
Sample Output
0 9 8 7 6 5 4 3 2 1
HINT
只提交begin和end之间的代码。
#include<iostream> using namespace std; int main(){ int array[10]; int i; for(i=0;i<10;i++)//输入数据元素 cin>>array[i]; //数组元素逆序存储 //---------------begin---------- int t; for(i=0;i<5;i++) { t=array[9-i]; array[9-i]=array[i]; array[i]=t; }//---------------end------------ for(i=0;i<10;i++)//输出数组元素 cout<<array[i]<<" "; return 0; }
0 0
- Problem D: 数组----逆向存储
- CodeForces 527D Clique Problem 树状数组
- Problem D: 求数组元素的和
- Problem D: 整型数组运算符重载
- Problem D: 数组类(II)
- Problem D: 数组类(II)
- Problem D: 自定义实数及其数组
- 逆向工程 疯狂滴数组名 和 大小端存储
- CF 863D. Yet Another Array Queries Problem 逆向思维,递归
- Problem D
- Problem D
- Problem D
- problem D
- Problem D
- Problem D
- Problem D
- Problem D
- Problem-D
- 通过GOT覆写实现ret2libc - 64-bit Linux stack smashing tutorial: Part 3
- 用8进制和16进制创建字符串
- java/android中对回调函数深入灵魂的理解
- hdu 1037 Keep on Truckin'
- 剑指offer系列之16:树的子结构
- Problem D: 数组----逆向存储
- scikit-learn学习1.10. 决策树(Decision Trees)
- HDU 1878 欧拉回路(并查集&&欧拉回路)
- Android应用向su申请root权限,以及Superuser进行授权管理的原理浅析
- java作业。。。
- poj 1947(树形dp+背包问题)
- ZooKeeper中“会话”的那些事儿
- 【剑指offer系列】 不用加减乘除做加法___47
- MySQL基础三:约束和修改数据表