+ 2
know the required data type.
while coding when we get the constraints. then its important to choose the appropriate data type for the variable. for example. if 1<=var_num<=(10^28) 0<=var_test<=(10^5) so what will be the required data type for var_test and var_num? if we can design a program when we input the value. it will give the respective suitable data type.
6 Antworten
+ 4
thankx but produced infinite loop for my input
+ 3
no. i just want a scripted program.
for example if we enter a value, let that be in a string format. then the progam will analyze the value. and will tell the appropriate datatype of that value.
the out put would look like int or long int or double or long long. according to the value.
hope you got my question.
+ 1
Thank you. I understand it now, would be fun to create it.
+ 1
sorry for that.
https://code.sololearn.com/cEAjFDu2mVnK
This code does not need console.readline(). Because it loops through the array.
0
I do not really understand your question ? Are you looking for an AI for types. Do you want a questionaire. Saying 1) is it a whole number. Or do you want a string analyser, that analyses string input and convert the string in an approperiate type.
0
Have been busy working on it.
https://code.sololearn.com/c1pRZVe01xq7
This is what it is right now.
Funny to see that is recognizes
string StringG = "1.23E+11";
as a float
string StringA = "10^28";
string StringB = "10^5";
string StringH = "1.23 X 10^11";
So it does recognize "E" but not "^"
Can you refrase these string so, it would be a acceptable string for parse methods
I had in mind to implement 2 methods
1) with parse
2) by hand
But when doing the implentation of the parse method, it came in to my mind that there is no such thing a doing by hand in programming,
So the second method is not implement
edit : removed second method and user input request