help with code
Need to get 100 pairs at the same time And need console to find what Is the smallest number out of the all the big number
42 Replies
aight, what's the code so far?
and what do the pairs represent
a small and a big number?
Pair is input from user
User need to input 100 pair
I need console to get those 100 pair find the biggest of every pair
And what is the smallest number out of all this
so the smallest and biggest of all the pairs?
Nope output is the smallest number out of all of biggest number
For example
(8,9),(1,6) (7,3)(2,4)
Output is 4
Cuz the biggest number is 9,6,7,4 and the smallest of them is 4
Sure, makes sense
What code do you have so far?
Got the basic only
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/using System;
class Program
{
static void Main()
{
Console.writeLine("Hello, please enter 100 pairs of number in this format (num,num)”)
} }
} }
Ah, so you don't even have the user input
Start with that
Save it as something or like
Uh, in a variable probably, yes
But like how do I spilt the pairs
Or I save all 100 as the same int
Who says the same int?
Use a list
And the elements of each pair could be stored in, let's say, a tuple
Or another list/array
Splitting? Easy,
.Split()
You might also want to .Trim()
the parentheses
And then int.Parse()
the strings to actual integersImma check teacher if I can use it we haven’t learned it yet
If I do spilt how is it going to split
Like by what
By what you want
.Split()
does take argumentsOh like .split(-)
And it’s gonna split between each -?
Yep
Angius
REPL Result: Success
Result: string[]
Compile: 411.928ms | Execution: 26.073ms | React with ❌ to remove this embed.
It’s just .split or what is before
See the code above
So like save input as a and then
a.split(-)?
You could, yeah
So imma add it and get back to u
Teacher say I can’t use split
I can use
While string
For string
String
If
Math
And the basic
Not even a
foreach
loop?
Still, it's doable
You'll just have to parse the input manually
Use the fact, that each string is just an array of characters
So you can go through all the characters in order
If the first one is (
, discard it, continue
If the next one is a numeric char, add it to some buffer
Keep doing that until you encounter a comma
Then keep adding the numeric chars to another buffer, until you encounter a closing parentheses or end of the string
We can check if a character is numeric with simple maths
We use the fact that chars are just integers in disguiseAngius
REPL Result: Success
Result: <>f__AnonymousType0#1<int, int>
Compile: 287.926ms | Execution: 80.486ms | React with ❌ to remove this embed.
We're looking for chars in this range
All of them will be numeric, that is
0
to 9
I think the number can be everything that can be in int
Not for m0-9
But we're stepping through the string char by char
That's why I mentioned using a buffer of some sort
So how am I about to split
Even manually have no idea how do u split it
For example
You'd do the same but with two buffers
Don’t think we learn that also
Learn what?
Loops?
Strings?
Variables?
It's not some fancy concept, just a loop, two
string
variables, and a couple of if
s
And a couple of boolsBuffer
Or am I just dumb
What is buffet stand for
Just a string variable you add to
string a = ""
And then you can append the numeric chars to itAngius
REPL Result: Success
Result: string
Compile: 441.765ms | Execution: 37.697ms | React with ❌ to remove this embed.
Like so
So u got string a
Du did and 5 and 7
It’s add it up to 57
Just would that help up divide
Because you will have two variables
a
and b
Look at the example I sent
Specifically at the position of the ^
Before you encounter the comma, keep adding to a
This?
After you encounter the comma, keep adding to
b
This https://discord.com/channels/143867839282020352/1186197714824867850/1186208281149050941Angius
Quoted by
<@85903769203642368> from #help with code (click here)
React with ❌ to remove this embed.