新手求助

P5719 【深基4.例3】分类平均

胡风千里惊 @ 2020-03-31 20:13:14

输出不正常,望大佬看看//请@我

#include<iostream>
using namespace std;
int main(){
    int an,bn,k,n,as,bs;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%k==0){
            as+=i;
            an++;
        }
        else {
            bs+=i;
            bn++;
        }
    }
    printf("%.1lf %.1lf",double(as)/an,double(bs)/bn);
}

by pikabi @ 2020-03-31 20:14:11

@胡风千里惊 头文件<cstdio>


by pikabi @ 2020-03-31 20:14:50

#include<cstdio>

by comfort @ 2020-03-31 20:19:00

iostream包括C语言哇


by comfort @ 2020-03-31 20:19:13

除了freopen


by 血色黄昏 @ 2020-03-31 20:33:52

万能头不香么


by guojiale @ 2020-05-19 16:54:44

@血色黄昏 万能头是什么


by 血色黄昏 @ 2020-05-19 17:16:28

@guojiale 这么老的帖子您都能翻出来...万能头就是

#include<bits/stdc+.h>

by yinao @ 2020-07-17 19:21:38

@血色黄昏 #include<bits/stdc++.h>


by 血色黄昏 @ 2020-07-17 19:52:54

@yinao 咳咳咳zyx


|