ACM's ACMer rookie experience of input

  Freshman begin to understand the ACM, interest dictates, Liu Rujia read some books written, erudite, so the record is not updated regularly.

  ACM input:

  

#define LOCAL
#include <stdio.h>
int main()
{
#ifdef LOCAL
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
#endif
    printf("Hello World!\n");
    return 0;
}

This is a typical competition code, where the method uses a redirection, build the code, the system automatically generates and data.in data.out two files in the current directory, the name suggests, data stored in the input portion .in, the output section is stored in data.out, and then judge and OJ systems, redirected part is written between #ifdef and #endif, its meaning is: You must define LOCAL, to compile two freopen statement.

 

In addition, C language of many abbreviations, Knowing full name, you can have a deeper understanding of it, for example, stdio called the Standard Input and Ouput (standard input and output), stdlib called the standard libarary (standard library).

 

ACM input (with my experience) are the following:

1. Direct input // Not much to say

2. Multi-group input

Multiple sets of input is divided into two, one is the result of a case of an input, an output of the case immediately

#include <stdio.h>
int main()
{
    int n,i,a;
    while(scanf("%d",&n) != EOF) {
        while(n--) {
            scanf("%d",&a);
            printf("%d\n",!a);
        }
    }
    return 0;
}

Which means that EOF End Of File, ACM is a thing often used.

Another group is a multi-input multi-output, in an array, can result.

Guess you like

Origin www.cnblogs.com/xdaniel/p/12013995.html