3 条题解

  • 2
    @ 2024-8-12 17:52:35
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,j=0,o=0;
    	cin>>n;
    for(int i=1;i<=n;i++){
     	if(i%2==0){
     		o=o+i;
    	 }
    	 else{
    	 	j=j+i;
    	 }
    	}
    	cout<<j<<" "<<o;
     	
    	          	return 0;
    	          }
    
    • 1
      @ 2024-8-18 8:46:43

      7ftdu3tewq09hsijhy

      • 0
        @ 2024-8-12 17:52:51

        using namespace std;
        int main(){
        int n,a=0,s=0;
        cin>>n;
        for(int i=1;i<=n;i++){
        if(i%2==0){
        a=a+i;
        }
        else{
        s=s+i;
        }
        }
        cout<<s<<" "<<a;
        return 0;
        }
        ---
        • 1

        信息

        ID
        279
        时间
        1000ms
        内存
        32MiB
        难度
        4
        标签
        递交数
        55
        已通过
        27
        上传者