dalao看一下哪错了

P2669 [NOIP2015 普及组] 金币

Celius @ 2021-08-20 11:18:57

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",n);
    int sun=1;
    int ans=0;
    for(int i=1;;i++){
        for(int j=1; j<=i; j++){
            if(sun>=n){
                cout<<ans;
                return 0;
            }
            ans+=i;
            sun++;
        }
    }
    cout<<ans;
    return 0;
}

by qwq___qaq @ 2021-08-20 11:23:45

@sandianshui 输入没加取地址符……


by qwq___qaq @ 2021-08-20 11:25:04

@sandianshui 还有就是第十行是判断 sum>n,不能加等号。


by Celius @ 2021-08-20 11:26:43

@pengzijun 地址符是啥


by 求学的企鹅 @ 2021-08-20 11:27:04

@sandianshui
第 5 行:scanf("%d",&n);
第 10 行:if(sun>n){


by Celius @ 2021-08-20 11:27:46

还是错的


by 求学的企鹅 @ 2021-08-20 11:30:02

@sandianshui 你确定?


by Celius @ 2021-08-20 11:38:34


by Celius @ 2021-08-20 11:38:57

有毒


by Celius @ 2021-08-20 11:39:26

我怎么是错的


by Celius @ 2021-08-20 11:41:24

对了


|