hdu 1004
2015-02-03 12:37
375 查看
hdu 1004
至于这道题,不会的看看二维字符串就行了。
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
int n, i, j, b[1500],max;
char a[1500][30];
while(scanf("%d",&n) , n != 0)
{
memset(b,0,sizeof(b));
for(i = 0; i< n; i++) scanf("%s",a[i]);
for(i = 0; i< n; i++)
for(j = i+1; j < n; j++)
if(strcmp(a[i],a[j]) == 0 && b[j] == 0) b[j] = 1,b[i]++; // 遍历两次数组就行,不会超时的.
for(i = 0, max = 0; i < n; i++) if(b[i] > b[max]) max = i;
printf("%s\n",a[max]);
}
return 0;
}
至于这道题,不会的看看二维字符串就行了。
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
int n, i, j, b[1500],max;
char a[1500][30];
while(scanf("%d",&n) , n != 0)
{
memset(b,0,sizeof(b));
for(i = 0; i< n; i++) scanf("%s",a[i]);
for(i = 0; i< n; i++)
for(j = i+1; j < n; j++)
if(strcmp(a[i],a[j]) == 0 && b[j] == 0) b[j] = 1,b[i]++; // 遍历两次数组就行,不会超时的.
for(i = 0, max = 0; i < n; i++) if(b[i] > b[max]) max = i;
printf("%s\n",a[max]);
}
return 0;
}
相关文章推荐
- HDU 4669 Mutiples on a circle (2013多校7 1004题)
- HDU 1004
- HDU 4669 Mutiples on a circle (2013多校联合7 1004)
- HDU-ACM-1004
- hdu-1004
- 【map热手题】HDU 1004—Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004
- HDU-1004 Let the Balloon Rise(STL: map)
- hdu 6088 Rikka with Rock-paper-scissors (2017 多校第五场 1004) 【组合数学 + 数论 + 模意义下的FFT】
- HDU 5715 & 2016"百度之星" 复赛(Astar Round3)1004 XOR游戏(Trie)
- HDU 1004
- Hdu 1004 Let the Balloon Rise
- HDU-2017 ACM/ICPC Asia Regional Shenyang Online-1004-array array array
- hdu 1004 let the balloon rise
- HDU-2017 多校训练赛4-1004-Dirt Ratio
- hdu 1004 Let the Balloon Rise
- acm_hdu Problem Archive 1004
- HDU 1004 Let the Balloon Rise
- 【HDU 1004】Let the Balloon Rise(STL+水题)