1 条题解

  • 0
    @ 2025-1-17 14:58:36
    
    
    #include<iostream>
    #include<string>
    #include<algorithm>
    #include<iomanip>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<stack>
    #include<queue>//习惯勿喷
    //#include<bits/stdc++.h>
    using namespace std;
    int a[15],n;//定义变量
    void prt(int k){//有参无返输出prt函数int k
    	for(int i=0;i<k;i++){
    		cout<<a[i]<<"-";//输出a[i]
    	}
    	cout<<a[k]<<endl;
    }
    void dtry(int i,int k){//有参无返dtry
    	a[k]=i;
    	if(i==n){
    		prt(k);
    	}
    	else if(i<n){
    		dtry(i+1,k+1);
    		dtry(i+2,k+1);
    	}
    	return;
    }
    int main(){
    	cin>>n;
        dtry(0,0);
    	return 0;
    }
    
    • 1

    信息

    ID
    655
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    (无)
    递交数
    27
    已通过
    14
    上传者