質問編集履歴

1

コードを書きなおしました

2020/05/21 05:32

投稿

grape_ll
grape_ll

スコア83

test CHANGED
File without changes
test CHANGED
@@ -82,53 +82,69 @@
82
82
 
83
83
  int main(void){
84
84
 
85
- int num[100000],a;
85
+ int a[10000];
86
86
 
87
- int i=0,ans,ans1=0;
87
+ int count=1;
88
88
 
89
- int count=0;
89
+ int ans_num,ans_cnt=0;
90
90
 
91
- while(1){
91
+ int i=0,j=0;
92
92
 
93
- if((scanf("%d",&num[i]))==EOF) break;
93
+
94
94
 
95
- if(i==0) count++;
95
+ while(1){
96
96
 
97
- else if(num[i]==num[i-1]){ count++; printf("%d::\n",count);}
97
+ if((scanf(" %d",&a[i]))==EOF) break;
98
98
 
99
- else {
99
+ printf("%d:\n",a[i]);
100
100
 
101
- if(ans1<=count){
101
+ i++;
102
102
 
103
- ans1=count;
103
+ }
104
104
 
105
- ans=num[i-1];
106
105
 
107
- count=1;
108
106
 
109
- printf("%d:%d\n",ans1,ans);
107
+ for(j=0;j<i-1;j++){
110
108
 
111
- }
109
+ if(j!=0){
112
110
 
113
- }
111
+ if(a[j]==a[j-1]){
114
112
 
115
- i++;
113
+ count++;
116
114
 
117
- }
115
+ }
118
116
 
119
- if(ans1<=count){
117
+ else{
120
118
 
121
- ans1=count;
119
+ if(ans_cnt<=count){
122
120
 
123
- ans=num[i-1];
121
+ ans_cnt=count;
124
122
 
125
- printf("%d:%d\n",ans1,ans);
123
+ count=1;
126
124
 
127
- }
125
+ ans_num=a[j-1];
128
126
 
129
- printf("%d %d\n",ans1,ans);
127
+ }
130
128
 
129
+ }
130
+
131
+ }
132
+
133
+ }
134
+
135
+
136
+
137
+ if(ans_cnt<=count){
138
+
139
+ ans_cnt=count;
140
+
141
+ ans_num=a[j-1];
142
+
143
+ }
144
+
145
+ printf("%d %d\n",ans_cnt,ans_num);
146
+
131
- return 0;
147
+ return 0;
132
148
 
133
149
  }
134
150