CodeForce 614B Gena's Code(水题)

这道题提醒我两点:

1.break时一定要检查清楚

2.字符串直接赋值一定要注意结束符,最好能用strcpy

以上是debug的惨痛教训

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

#define MEM(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define debug printf("!/n")
#define INF 1000
#define MAX(a,b) a>b?a:b
#define blank pf("
")
#define LL long long

char str[100010];

int main()
{
          int n,i,j;
          while(~sf("%d",&n))
          {
               int cnt = 0;
               bool flag=false;
               for(i = 0;i<n;i++)
               {
                    char tmp[10];
                    sf("%s",tmp);

                    if(tmp[0]=='0')
                    {
                              flag = true;
                              continue;
                    }

                    if(tmp[0]!='1')
                    {
                              strcpy(str,tmp);
                              continue;
                    }
                    else
                    {
                              int len = strlen(tmp);

                              for(j = 1;j<len;j++)
                              {
                                        if(tmp[j]!='0')
                                        {
                                                  strcpy(str,tmp);
                                                  break;
                                        }
                                        cnt++;
                              }
                    }
               }
               if(flag)
               {
                    pf("0
");
                    continue;
               }
               if(strlen(str)==0)
               {
                    pf("1
");
                    continue;
               }
               pf("%s",str);
               while(cnt--){pf("0");}
               blank;
          }
          return 0;
}
原文地址:https://www.cnblogs.com/qlky/p/5154453.html