_北城 2019-09-07 13:11 采纳率: 100%
浏览 298

后面乱码出现的原因是什么? 什么情况下还会出现这种类似的乱码??

后面乱码出现的原因是什么? 什么情况下还会出现这种类似的乱码??

#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(int score[],int m, int below[])
{
    int i,sum=0,count=0,j,k=0;
    float av=0.0;
    for(i=0;i<m;i++)
    {
        sum+=score[i];
        count++;
    }
    av=sum/m;
    for(j=0;j<m;j++)
    {
        if(score[j]<av)
        {
            below[k++]=score[j];
        }
    }
    return count;

}
void main()
{
  FILE *wf;
  int i, n, below[9];
  int score[9]={10,20,30,40,50,60,70,80,90};
  system("CLS");
  n=fun(score, 9, below);
  printf("\nBelow the average score are: ");
  for(i=0;i<n;i++)  
     printf("%d ",below[i]);
/******************************/
  wf=fopen("out.dat","w");
  for(i=0;i<n;i++)  
     fprintf(wf,"%d ",below[i]);
  fclose(wf);
/*****************************/
}

```![图片说明](https://img-ask.csdn.net/upload/201909/07/1567833092_247668.png)
  • 写回答

1条回答 默认 最新

  • qtchen_1988 2019-09-07 14:26
    关注
    #include <conio.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    int fun(int score[],int m, int below[])
    {
        int i,sum=0,count=0,j,k=0;
        float av=0.0;
        for(i=0;i<m;i++)
        {
            sum+=score[i];
            count++;
        }
        av=(float)sum/m;
        for(j=0;j<m;j++)
        {
            if(score[j]<av)
            {
                below[k++]=score[j];
            }
        }
        return count;
    
    }
    void main()
    {
      FILE *wf;
      int i, n, below[9]={};
      int score[9]={10,20,30,40,50,60,70,80,90};
      system("CLS");
      n=fun(score, 9, below);
      printf("\nBelow the average score are: ");
      for(i=0;i<n;i++)
         printf("%d ",below[i]);
    /******************************/
      wf=fopen("out.dat","w");
      if(wf)
      {
          for(i=0;i<n;i++)
              fprintf(wf,"%d ",below[i]);
          fclose(wf);
      }
    /*****************************/
    }
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同
  • ¥15 excel 上下按钮 显示行
  • ¥20 云卓h12pro 数传问题
  • ¥20 请问有人知道怎么用工艺库里面的sdb文件通过virtuoso导出来library里面每个cell的symbol吗?
  • ¥20 海思 nnie 编译 报错
  • ¥50 决策面并仿真,要求有仿真结果图