Trial Test for Autotester position

You have 3 hours to complete the Test. During writing the test it is allowed to use any programming language, any literature. In order to pass this test successfully you should garner more than 50-60 points.

    HELP:
  • If during writing tasks 3, 5, 6 you have forgotten the title of the necessary library function, you may think up your own title for it, describe its function and its arguments in the comments and use it further when fulfilling the task. The only restriction: this function should be analogous of the really existing function in the standard library.
  • In task assignments 2 and 4 the input line is guaranteed not to have tabulation symbols and the end of the line ('\n').

Task 1 (18 points)

Please draw a block-scheme that realizes the next algorithm:
There is an input file INF with successive access (operations of opening and closing the file are allowed, checking of the end of the file, reading of the current line and going to the next line’s entry). The file contains records of the same structure, sorted out in the ascending order of values of integer key field that is contained in the records. There could be records contained of the same key value in the INF file. You are required to create and input file OUTF, which is formed out of the input file INF by the following rules: If for some value of the key the record with the value of the key is absent in the INF file then this record should be missing in the file OUTF also. If for a certain value of the key in the INF file there is present only one record with the same value of the key field, then this record must be copied to OUTF file. If for a certain value of the key in the INF file there is present some odd number of records with the same value of the key field, then to the file OUTF the should be only that record copied from the aggregate which is physically located as first in the INF file among the records with a given key value. If for a certain key value in the file INF there exists some even number of records with that value of the key field, then file OUTF should contain the copy of the record from this aggregate which is physically located as last in the INF file among all other records with the given key value. For example: INF: k2, k3, k4a, k4b, k4c, k8, k99a, k99b, k100a, k100b, k100c, k100d OUTF: k2, k3, k4a, k8, k99b, k100d.

Task 2 (15 Points)

Please write a function char* superSort (char*) that receives a line of words divided by blanks.
Each word may consist of latin letters in the lower-case and numbers. The result returned should be the line from the received words that are sorted out in the alphabetic order being divided by blanks, meanwhile at the time of the sorting out when comparing words numbers should be ignored as if they do not exist. For example: for the input line ma79ma 9n8e7 mila r1a2m3u results of the work of the function should be the following: ma79ma mila 9n8e7 r1a2m3u

Task 3 (15 points)

Publishing house placed an order for a program of АРМ editor, which should simplify work with different editions (versions) of books. Each book may contain chapters, sub-chapters, sub-sub-chapters, sub-sub-sub-chapters and so on… Each (sub...) chapter may contain other subchapters, usual text, lists of homogeneous textual elements (such are found in dictionaries, catalogues and others), illustrations and automatically created objects (such as captions, indices and so on). The author of the book may be both a team and a stand-alone person. Different editions of the same book may be different in contents and even in the list of authors, however not in the title. It is necessary to make a design of classes hierarchy for the system described and draw corresponding non-detailed classes diagram. Close to the diagram there should obligatorily be a detailed description of the used notation (preferably, via UML).

Task 4 (8 points)

Describe in your own words realization of the idea of functional realization: int printSubSets (char *) that receives input line of words divided by blanks and printing all non-blank subsets of the aggregate of words (each subset in a separate line). For example, for the input line:
мама мыла раму
This function should give the following results:
мама мыла раму
мама мыла
мыла раму
мама раму
мама
мыла
раму
Please suggest the returned value. Your text description of the algorithm should be short, clear and understandable to the coder, that has allegedly lower level of qualification then you do.

Task 5 (35 points)

Write a function int printMinQuantity (unsigned int input_value), which takes integer value “input_value” and prints it on the screen as a line of simple numbers divided by blanks the sum of which is the value assigned “input_value”. Meanwhile the quantity of simple numbers should be minimal – so that you can’t select a shorter sequence of simple numbers that amount to the sum of input_value. For example, for number “6” the correct are the following variants: "5 1" or "3 3", and the incorrect are the following variants: "3 2 1", "2 2 2", "1 1 1 1 1 1" and so on. You should find all the non-correct variants; it is enough to have any. While writing the function please pay a special attention to the guarantee that your algorithm finds actually the shortest of the allowed sequences of simple numbers and also, to the effectiveness of the algorithm. Please suggest the variant of the value that is returned by the function.

Task 6 (35 points)

Please write a program which takes one argument of the command line.
It is supposed that the argument contains the name of the file with which the given program will be working. Input file is guaranteed to contain code in С++, written according to С++ standards, also containing comments. If in the parameter given by the command line the extension is not mentioned, then it is supposed that .срр is the extension of the file. Your program should create two files our of the source file with the extension replaced as follows: .src and .rem respectively. The file with the extension .src should contain only the code from the input file, and all the comments should be replaced for blanks. The file with the extension .rem should contain only comments, however all the code of the program should be replaced for blanks. The program should correctly (according to the rules of С++) process code that contains:
"included" into each other comments (e.g. /*   //   */ );
Various text lines (e.g. containing "//", "/*" and so forth);
Symbols of line extension (backslash at the end of the line);
Trigraphs;
And others.