Connection Status:
Competition Arena > CalcTest
SRM 246 · 2005-06-09 · by Andrew_Lazarev · String Manipulation
Class Name: CalcTest
Return Type: String[]
Method Name: uniform
Arg Types: (vector<string>)
Problem Statement

Problem Statement

You are developing a new software calculator. During the testing phase of the software you have found that the test cases use different symbols as the decimal point of floating numbers. Moreover some test cases contain useless space symbols. Now you want to bring the numbers to a unified format.

You will be given a String[] numbers. Remove all space symbols (ASCII code 32) from the given numbers and replace each non-digit symbol with a dot symbol ('.'). You should not make any other changes to the numbers.

Constraints

  • numbers will have between 1 and 50 elements, inclusive.
  • Each element of numbers will contain between 1 and 50 characters, inclusive.
  • Each character in numbers will have ASCII code between 32 and 127, inclusive.
  • Each element of numbers will contain at most one non-space non-digit symbol.
  • Each element of numbers will contain at least one digit.
Examples
0)
{"1.5", "2$ 3", "12 3"}
Returns: {"1.5", "2.3", "123" }
1)
{",5", "3,", ".5", "3.", "000,000", "000 000"}
Returns: {".5", "3.", ".5", "3.", "000.000", "000000" }
2)
{"263C45233 ", " 2364A56", "B273664"}
Returns: {"263.45233", "2364.56", ".273664" }
3)
{"814777132","4/5","o216673","362521528","3","04"}
Returns: {"814777132", "4.5", ".216673", "362521528", "3", "04" }
4)
{"19194939","17651J8192","\"52","6J0","1855213"," 19_9677"}
Returns: {"19194939", "17651.8192", ".52", "6.0", "1855213", "19.9677" }

Submissions are judged against all 53 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class CalcTest with a public method vector<string> uniform(vector<string> numbers) · 53 test cases · 2 s / 256 MB per case

Submitting as anonymous