|
||||||||||
Code FormattingTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 388 Accepted Submission(s): 46 Problem Description As we all know, a piece of code may include variable, function and some other program statements such as if, else, while, for, etc. Usually we cannot guarantee our code is absolutely right. When you didn't get the verdict - 'Accepted', you would start debugging. So in ACMICPC contests, we have team-mates to help us. When you copy a program to windows from linux and open it with notepad, you can see all in one line. Of course, the code can be compiled with g++ on linux, but it's not formatted, so it's too hard to read it. Now you are given a piece of code, and your task is to format the code to make it good. To make it simple, we define the code only contain header file, variable, function, if, for, printf, scanf, and expression(e.g. a = b + 1) Also a piece of code is called good if it obey as follows: 1. header file A space between #include and <XXX> is required. And XXX in <> can be any correct header file. You can only declare one header file in one line. It is guaranteed that all header files declaration are at the very beginning of the code. A blank line is required after all header files if header files exist. 2. variable declaration X A, B, C, ...; Assuming that X can be only int, double, bool or char, and there must be at least one space after X. You can only declare one type of variable in one line. The comma(,) is used to split variables in one type in one line. And a space is required after the comma(,). It is guaranted that there must be a space between X and A. A, B, C, ..., are the name of variable, and guarantee that no calculation, just declaration. The name of variable can be any except "scanf" and "printf". 3. function X Y(A a, B b, ...){} X is the type of the function, which can be 4 variables above plus void. Y is the name of the function, which can be any except "scanf" and "printf". A and B the type of variable a and b, and a, b is the name which can be any. A space is required between X and Y, A and a, B and b. ... means if the function have more parameters, the format is the same as above. There can be any parameters(0 included) in each function. It is guaranteed that there will be a space between X and Y. A space is required after each ",". 4. if if(X){} X is an expression There must be { and } after if(X). 5. for for(X; Y; Z){} X, Y, Z are three expressions split by ;, and a space is required after each ;. There must be { and } after for(X; Y; Z). X, Y, Z can be empty (e.g. for(; ; ), for(X; ; Z), for(; Y; ), etc) 6. printf printf("X", Y, Z, ...); X in "" is a string which you shouldn't change it. Y, Z, ... are expressions split by ,, and a space is required after each ",". The number of expressions can be 0 or more. 7. scanf scanf("X", &Y, Z, ...); Abosolutely the same with printf 8. expression There could be variables, operator(+, -, *, /, =, <, >, >=, <=, ==, !=) and some constant. For each operator, a space is required for both sides. 9. function X(A, B, C, ...); You can call a function after your declaration. Especially, whatever the type your function is, there will be no return in function's {}. A, B, C, ... are expressions. Function call cannot appear in expressions. Although this may be rediculous, it's much more easier for your coding. A space is required after each ",". In addition, there can be many expressions, scanf, print, variable declaration inside {} { and } should both take up one line. The rule inside {} is the same, but should start with two more space. In all, all characters appear in your code can be only [a-z][A-Z][0-9]<>()\+-*/=!,;.%&#"' and space. The sample involved all rules above. Just have a look at it to unstander better. It is guaranteed that the code after formatting can be compiled by g++, so your task is only to format it! Input Multiple cases(no more than 100), each case is a piece of code in one line. The length of each piece of code, which in one line, is no more than 1000. Output For each case, please output Case #k: in one line first, which k starts from 1. And then please output the code which is called good. Sample Input
Sample Output
Source | ||||||||||
|