4 solutions

  • 1
    @ 2026-8-6 15:22:59

    for循环版

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
    	cin>>n;
    	for(int i=0;i<=n;i++)
    	{
    		if(i<=n)
    		{
    			cout<<i<<" ";
    		}
    	}
    	return 0; 
    }
    
    • 0
      @ 2025-7-8 10:18:27
      #include<bits/stdc++.h> 
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          int i=0;
          while(i<=n)
          {
              cout<<i<<' ';
              i++;
          }
          return 0;
      }
      
      • -2
        @ 2026-3-7 20:15:32

        for做不行吗

        • -2
          @ 2026-3-7 20:14:48

          这都做不来?! 你钱白交了。。。

          • 1

          Information

          ID
          44
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          1
          Tags
          (None)
          # Submissions
          287
          Accepted
          114
          Uploaded By