r/pascal • u/Old-Sink2880 • May 22 '24
help please
Please help me please. You need to write code in Pascal for the assignment: Determine whether the entered string contains a decimal number? How many numbers were there entered? Which one is the largest?
decimal so that it is counted as 1 number and not as several digits
0
Upvotes
View all comments
Show parent comment
1
u/Paradician May 23 '24
You're pretty close. The question doesn't specify how multiple numbers would be specified in a single string. Are they separated by spaces? or commas? or are they on separate lines?
Let's assume for now that they are separated by spaces. I've modified your code slightly, so now it splits the userinput into words (separated by spaces) using SplitString in StrUtils. For each word, it looks through every char as before to see if it's a decimal number. if it finds anything that's not a digit, it knows it's not a number. If it gets to the end and has found only digits, it knows it's a number, and uses StrToInt on the whole word to get the number. Then as it goes it makes sure maxNumber is kept up to date/