标题:请问这个问题要怎么编?
取消只看楼主
清风幽然
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-25
结帖率:66.67%
已结贴  问题点数:20 回复次数:2 
请问这个问题要怎么编?
You are given a file containing an unknown amount of numbers. Each number
is one of the numbers 1 to 9. A number can appear zero or more times and can
appear anywhere in the file. The number 0 indicates the end of the data. Some
sample data are:

5 3 7 7 7 4 3 3 2 2 2 6 7 4 7 7
2 2 9 6 6 6 6 6 8 5 5 3 7 9 9 9 0

Write a program to read the data once and print the number that appears the most in
consecutive positions and the number of times it appears. Ignore the possibility of a tie.
For the above data, output should be 6  5.

试了很多次都不对
搜索更多相关主题的帖子: and file data the number 
2019-09-26 16:25
清风幽然
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-25
得分:0 
回复 2楼 自学的数学
#include <stdio.h>
int main (){
 int s,n=0;
 FILE *in=fopen("a.txt","r");
 fscanf (in,"%d",&s);
 while (s!=0){
  if (s=s) { n++; }
  else if (n<n) { n=n; }
   fscanf (in,"%d",&s);    }
   printf ("%d %d",s,n);
   fclose(in);
}
 
  
2019-09-26 16:53
清风幽然
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-25
得分:0 
回复 4楼 rjsp
感谢!虽然你写的一部分还没学
2019-09-26 21:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-497024-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.098468 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved