zoukankan      html  css  js  c++  java
  • HDU 1004 Let the Balloon Rise

     

    求哪种颜色的球最多

    直接上代码 

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 
     5 using namespace std;
     6 char clour[1005][20];
     7 int numb[1005];
     8 int main()
     9 {
    10     int n,flag,maxn;
    11     char tmp[20];
    12     while(~scanf("%d",&n) && n){
    13 
    14         memset(clour,0,sizeof(clour));
    15         memset(numb,0,sizeof(numb));
    16         for(int i=0;i<n;i++){
    17             flag=0;
    18             scanf("%s",tmp);
    19             for(int j=0;j<=i;j++){
    20                 if(strcmp(tmp,clour[j]) == 0){
    21                     numb[j]++;
    22                     flag=1;
    23                 }
    24             }
    25             if(flag == 0){
    26                 strcpy(clour[i],tmp);
    27                 numb[i]++;
    28             }
    29         }
    30         maxn=numb[0];
    31         for(int i=0;i<n;i++){
    32           //  printf("clour[%d] = %s   ",i,clour[i]);
    33          //   printf("numb[%d] = %d
    ",i,numb[i]);
    34             if(maxn<numb[i])
    35                 maxn=numb[i];
    36         }
    37         for(int i=0;i<n;i++)
    38             if(maxn == numb[i]){
    39                 maxn=i;break;
    40             }
    41 
    42         printf("%s
    ",clour[maxn]);
    43     }
    44     return 0;
    45 }
    ---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
  • 相关阅读:
    软件开发术语
    网络规划与设计
    MPLS LDP协议
    MPLS 基础
    CallAfter
    LongRunningTasks
    Non-blocking GUI
    WorkingWithThreads
    Python: Running Ping, Traceroute and More
    wxPython and Threads
  • 原文地址:https://www.cnblogs.com/livelihao/p/5155047.html
Copyright © 2011-2022 走看看