2022-12-10电子学会 青少年软件编程(C语言)等级考试二级 T1 数组逆序重放

1105:数组逆序重存放

信息学奥赛一本通(C++版)在线评测系统

2687:数组逆序重放

OpenJudge - 2687:数组逆序重放

1.6编程基础之一维数组 04:数组逆序重放

OpenJudge - 04:数组逆序重放




C++参考代码一:

#include "iostream"
#include "iomanip"
using namespace std;
int main( void )
{
	int count;
	int num[100];
	cin>>count;
	for(int i=0;i<count;i++)
	{
		cin>>num[i];
	}
	int n=count;
	int temp = count-1;
	if(count%2==0)
		count=count/2;
	else
		count=(count-1)/2;

	for(int i=0;i<count;i++)
	{
		int m;
		
		m=num[i];
		num[i]=num[temp];
		num[temp]=m;
		
		temp--;
	}
	for(int i=0;i<n;i++)
	{
		cout<<num[i]<<" ";
	}
	return 0;
}


C++参考代码二:

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101];
	
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	
	for(int i=n;i>=1;i--)
	{
		cout<<a[i]<<" ";
	}
	
	return 0;
}


C++参考代码三:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,ni=1;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	memcpy(b,a,sizeof(a));
	for(int x=n;x>0;x--)
	{
		a[x]=b[ni];
		ni+=1;
	}
	for(int m=1;m<=n;m++)
	{
		cout<<a[m]<<" ";
	}
	return 0;
}


C++参考代码四:

#include<iostream>
using namespace std;
int main(){
	int n;
	
	cin>>n;
	
	int num[n],ans[n];
	
	for(int i=0;i<n;i++){
		cin>>num[i];
		ans[n-1-i]=num[i];
	}
	
	for(int j=0;j<n;j++){
		cout<<ans[j];
		if(j==n-1)
		   break;
		cout<<" ";
	}
	
	cout<<endl;
	
	return 0;
}


C++参考代码五:

#include<bits/stdc++.h>
using namespace std;
stack <int> abc;
int main()
{
	int n,ans;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>ans;
		
		abc.push(ans);
	}
	
	for(int i=1;i<=n;i++)
	{
		cout<<abc.top()<<" ";
		abc.pop();
	}

	return 0;
}


python3代码:

n=int(input())
a=list(map(int,input().split()))

for i in a[::-1]:
            print(i,end=' ')




 


 




电子学会 青少年软件编程等级考试 C语言 2 级

电子学会 青少年软件编程等级考试 C语言 2 级_dllglvzhenfeng的博客-CSDN博客

电子学会青少年等级考试C语言(二级)

电子学会青少年等级考试C语言(二级)_电子学会c语言二级_dllglvzhenfeng的博客-CSDN博客




2020.6.21-参加中国电子学会的全国青少年软件编程等级考试C语言二级

2020.6.21-参加中国电子学会的全国青少年软件编程等级考试C语言二级_北理工附中J的博客-CSDN博客

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dllglvzhenfeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值