Zoj 2851 Code Formatter Water problem (1)

Source: Internet
Author: User
This previous game problem, today brush water problem saw again, at that time to see a large pile also did not see, now looked and see, I go, just do not understand what to do .... Really helpless, read someone else's code, DAWU: The original special is to ask for space and ' \ t ' quantity ah. Write the code, that is, the special is not the correct output ... Look at others code, two continue really puzzling, and then read the question, check the meaning of trailing spaces: I go, is special "trailing space" Ah ... Do not understand the problem, but also make a bird ah ....
#include <stdio.h>
#include <string.h>
int main ()
{ 
    int n,num1,num2,i,len,k;
    Char a[200000];
    scanf ("%d", &n);
    GetChar ();
    while (n--)
    {
        num1=num2=0;
        while (gets (a), strcmp (A, "# #")!=0)
        {
            Len=strlen (a);
            for (i=k=0;i<len;i++)
            {
                if (a[i]== ' \ t ')
                {
                    k+=4;
                    num2++;
                    Continue;
                }
                if (a[i]== ')
                {
                   k++;
                   Continue;
                }
                k=0;
           }
           num1+=k;
       }
       printf ("%d tab (s) replaced\n%d trailing space (s) removed\n", num2,num1);
    }  
     return 0;
  }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.