4 solutions

  • 0
    @ 2025-8-13 16:11:00
    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int main(){
    	cin>>n;
    	if(n==0){
    		cout<<0;
    	}else{
    		for(int i=0;i<=n;i++){
    		if(i%2!=0){
    			cout<<i<<' ';
    		}
    	}
    	cout<<endl;
    	for(int j=0;j<=n;j++){
    		if(j%2==0){
    			cout<<j<<' ';
    		} 
    	}
    	}
    	
    	return 0;
    }
    
    • 0
      @ 2025-3-23 15:58:46
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	long long n;cin>>n;
      	for(int i=0;i<=n;i++)if(i%2!=0)cout<<i<<' ';
      	cout<<endl;
      	for(int i=0;i<=n;i++)if(i%2==0)cout<<i<<' ';
      	return 0;
      }
      
      • -3
        @ 2024-7-5 9:39:59

        #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n;i+=2) { cout<<i<<" "; } cout<<endl; for(int i=0;i<=n;i+=2) { cout<<i<<" "; } return 0; }

        • -3
          @ 2024-6-2 11:41:10

          #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; for(int i=1;i<=n;i+=2) cout<<i<<" "; cout<<endl; for(int i=0;i<=n;i+=2) cout<<i<<" ";

          return 0;
          

          }

          • 1

          Information

          ID
          870
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          1
          Tags
          (None)
          # Submissions
          227
          Accepted
          81
          Uploaded By