永发信息网

13、 以下程序是统计一组数据中正数的和、正数的个数;零的个数;负数的和,负数的个数.数据以-999

答案:2  悬赏:60  手机版
解决时间 2021-02-03 06:55
  • 提问者网友:精神病院里
  • 2021-02-02 22:06
13、 以下程序是统计一组数据中正数的和、正数的个数;零的个数;负数的和,负数的个数.数据以-999
最佳答案
  • 五星知识达人网友:杯酒困英雄
  • 2021-02-02 22:47
//data file name is ddd.dat;#include #include main(){FILE *fp;int t,tag,z,f,l,sz,sf;if((fp=fopen(ddd.dat,r))==NULL)exit(1);while(!feof(fp)){fscanf(fp,%d,&t);if(t==-999)exit(2);if(t>0)tag=1;else if(t==0)tag=0;else tag=-1;switch(tag){case 1:z++;sz+=t;break;case 0:l++;break;case -1:f++;sf+=t;break;}fclose(fp);printf(%d Positive numbers are amount to %d\n z;sz);printf(%d Negative numbers are amount to %d\n f;sf);printf(%d Zero numbers \n,l);}
全部回答
  • 1楼网友:詩光轨車
  • 2021-02-02 23:24
我也是这个答案
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯