Submit | All submissions | Best solutions | Back to list |
PRINTF - Printf Parser |
In this task you have to parse a C language printf statement and print the output that will be produced on executing that statement in C. The statement will be of type printf("A",A1,A2,A3.....); where A consists of small latin alphabets, whitespaces and following format specifiers ( whitespaces will be present only in A ):
%d - signed decimal integer
%c - character
%f - decimal floating point( 6 digits after decimal point )
%s - character string
A1, A2, A3 ... are the arguments passed to printf statement and they will be equal to number of format specifiers mentioned. Their argument type will be same as that of format specifier i.e if specfier is '%c' the corresponding argument will be a character only. Input will always have at least one format specifier.
Input
First line of input contains a positive integer T denoting number of test cases. Following T lines have a valid printf statment containing less than 500 characters.
Output
Print the corresponding output given by the printf statement.
Example
Input:
2
printf("%c %d%f",'L',123,4.5);
printf("hello %f world %d nice %f computer %c is easy %s",2.34123245231,100,1.41414141,'S',"problem");
Output:
L 1234.500000
hello 2.341232 world 100 nice 1.414141 computer S is easy problem
Score : Source Code Length
Added by: | XeRoN!X |
Date: | 2011-02-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP |
hide comments
|
|||||
2015-05-24 14:51:55 Snehasish Sen
http://ideone.com/aV97sT The program works fine for me but I am getting WA. Somebody please check it. Last edit: 2015-05-24 14:53:57 |
|||||
2014-05-24 14:09:23 Sandeep Garhwar
is the string in its simplest form i.e "xyz" or could there also be a " in between? (Re:Author) : There is no such case like ab"c . Last edit: 2014-06-07 13:33:48 |
|||||
2014-01-23 10:46:04 Shashi Kant Prasad
Last edit: 2014-03-16 13:09:59 |
|||||
2013-10-27 21:04:17 houssem
@author i submetted a code that succeeds the simple test but in place of getting an "accepted" or "wrong answer" there is "3658" submission n°10362959 |
|||||
2013-10-27 18:19:05 houssem
plz check wat's rong with my submission n°10361890 i passed the test cases sample |
|||||
2013-07-04 21:14:03 Rana Saha
It's real fun reducing the source!!! :P :P Last edit: 2013-07-05 22:22:23 |
|||||
2013-06-28 18:10:02 Bhagwat
Accepted at first attempt.....:) |
|||||
2013-01-02 15:22:53 Aditya Pande
got it in 317 bytes... Last edit: 2013-01-02 15:33:39 |
|||||
2012-09-12 12:24:15 Mandar
got AC. :) just made a silly mistake thanks Last edit: 2012-09-13 05:47:47 |
|||||
2012-05-26 14:07:39 Aditya Pande
plz check whats wrong with submission 7042752 i tried all test cases any trick cases escape sequences %% etc Re ( Author ) : Your code gives wrong answer for 1 test case, rest is fine. Test with alternating %d %c sequence. EDIT: thnx i ll try and fix it Last edit: 2012-06-03 14:07:06 |