关于命名位置
  • 板块灌水区
  • 楼主MspAInt
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/12/11 11:15
  • 上次更新2023/10/24 08:01:09
查看原帖
关于命名位置
736801
MspAInt楼主2022/12/11 11:15

rt,例如下面的代码,n和a数组调换位置后会影响数组大小……

#include<bits/stdc++.h>
using namespace std;
int len,a[210]={},n;
int main(){
 cin>>n;
 a[1]=1;
 len=1;
 for(int i=1;i<=n-1;i++){
  int temp=0;
  for(int j=1;j<=len;j++){
   a[j]=a[j]*2+temp;
   temp=a[j]/10;
   a[j]=a[j]%10;
  }
  if(temp!=0){
   a[++len]=temp;
  }
  a[1]++;
 }
 for(int i=len;i>=1;i--) cout<<a[i];
 return 0;
}
2022/12/11 11:15
加载中...