Bootstrap

杭电OJ | 1004 Let the Balloon Rise 结构体数组排序

1004 Let the Balloon Rise

笔记:用memset对整个结构体数组进行初始化

如果结构体变量都是一致的,比如:

struct person{
    int age;
    int cost;
};
person per[10];
memset(per,0,sizeof(person)*10);

 但是不一致就像下面的代码一样逐一遍历吧,因为如果在结构体定义时就初始化就出现warning

struct person{
    int age;
    int cost=0;
};
[Warning] non-static data member initializers only available with -std=c++11 or -std=gnu++11

Input

Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

;