4 solutions

  • 1
    @ 2026-8-7 14:08:35

    用for循环的钱都白交了

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
    	cin>>n;
    	int t=1;
    	while(t<=n)
    	{
    		if(t%2==0)
    	    {
    		    cout<<t<<" ";
    	    }
    		t++;
    	}
    	return 0; 
    }
    
    • 1
      @ 2025-7-8 10:28:28
      #include<bits/stdc++.h> 
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          for(int i=1;i<=n;i++)
          {
              if(i%2==0) cout<<i<<' ';
          }
          return 0;
      }
      
      • 1
        @ 2025-7-8 9:47:24
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n,s=0;
            cin>>n;
            for(int i=1;i<=n;i++)
            {
                if(i%2==0) cout<<i<<' ';
            }
            return 0;
        }
        
        • 0
          @ 2024-12-17 20:39:52
          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
           int n;
           cin>>n;
           int f=1;
           while(f<=n-1)
           {
           	f=f+1;
           	cout<<f<<" ";
           	f++;
           }
           return 0;
          }
          
          • 1

          Information

          ID
          45
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          1
          Tags
          (None)
          # Submissions
          249
          Accepted
          102
          Uploaded By