ะกะปะพะฒะฐ, ะฟะพะผะพะณะธั‚ะต ะฟะพะถะฐะปัƒะนัั‚ะฐ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

ะกะปะพะฒะฐ, ะฟะพะผะพะณะธั‚ะต ะฟะพะถะฐะปัƒะนัั‚ะฐ

ะ’ะฐะผ ะดะฐะฝะฐ ะฟั€ะพะณั€ะฐะผะผะฐ, ะบะพั‚ะพั€ะฐั ะทะฐะดะฐะตั‚ ะผะฐััะธะฒ ะธะท 10 ัะปะพะฒ ะธ ะฟั€ะธะฝะธะผะฐะตั‚ ะฑัƒะบะฒัƒ ะฒ ะบะฐั‡ะตัั‚ะฒะต ะฒะฒะพะดะฝั‹ั… ะดะฐะฝะฝั‹ั…. ะะฐะฟะธัˆะธั‚ะต ะฟั€ะพะณั€ะฐะผะผัƒ ะดะปั ะฟะตั€ะตะฑะพั€ะฐ ะผะฐััะธะฒะฐ ะธ ะฒั‹ะฒะพะดะฐ ัะปะพะฒ, ัะพะดะตั€ะถะฐั‰ะธั… ะฟั€ะธะฝัั‚ัƒัŽ ะฑัƒะบะฒัƒ. ะŸั€ะธ ะพั‚ััƒั‚ัั‚ะฒะธะธ ะฟะพะดั…ะพะดัั‰ะธั… ัะปะพะฒ, ะฟั€ะพะณั€ะฐะผะผะฐ ะดะพะปะถะฝะฐ ะฒั‹ะฒะพะดะธั‚ัŒ "No match". ะŸั€ะธะผะตั€ ะ’ั…ะพะดะฝั‹ั… ะ”ะฐะฝะฝั‹ั… u ะŸั€ะธะผะตั€ ะ’ั‹ั…ะพะดะฝั‹ั… ะ”ะฐะฝะฝั‹ั… fun

19th May 2021, 1:13 AM
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ - avatar
7 Answers
+ 3
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ If {letter} is meant to store a single character from user input, try using: var letter = Console.ReadChar(); Then, you'll want to loop through the {words} string array and check each {word} to see if it contains the {letter}. foreach(var word in words) { if(word.Contains(letter)) { Console.WriteLine(word); } } Remember, the variables contain values. If the value is a collection of values, like your array, you'll likely need to loop through the collection to check each value. Notice how the foreach loop stores the current value in the loop to a variable called {word}. You can work with this variable in the context of the current loop cycle. Another basic loop you can use is the for loop: for(var i=0; i < words.Length; i++) { var word = words[i]; if(word.Contains(letter)) { Console.WriteLine(word); } } See if you can spot the similarities and differences. Hopefully, this helps connect some dots on the approach. ๐Ÿ‘Œ
19th May 2021, 1:43 AM
David Carroll
David Carroll - avatar
+ 3
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ There are several ways to determine "No match." However, I'll keep it simple by building from the loop example. I'll also describe the code so you can attempt to get it working. ๐Ÿ˜‰ The approach is to declare a new int variable named {wordsMatched} initialized to 0. This will be placed before the loop. Next, within the if block of the loop, add a line before or after Console.WriteLine(word) where the value for {wordsMatched} is incremented by 1. NOTE: This must be between the curly brackets of the if statement. Therefore, when a match is found in the loop, the word is printed to console and the {wordsMatched} value is increased by 1. After the loop, check if the value {wordsMatched} is equal to 0. If it is, then print "No match." Hopefully, this explanation gives you some guidance on how to do this second part. ๐Ÿ‘Œ
19th May 2021, 3:55 AM
David Carroll
David Carroll - avatar
+ 2
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ I'm not sure which challenge your attempting. Do you have a link?
19th May 2021, 2:20 AM
David Carroll
David Carroll - avatar
+ 1
ะฏ ะฒะพะพะฑั‰ะต ะฝะต ะผะพะณัƒ ะฟั€ะตะดะฟะพะปะพะถะธั‚ัŒ ะบะฐะบ ัั‚ะพ ะดะตะปะฐะตั‚ัั, ัƒ ะผะตะฝั ะตัั‚ัŒ ะบะพะด ะบะพั‚ะพั€ั‹ะน ะดะตะปะฐะตั‚ ะฟะตั€ะตะฑะพั€, ะฝะพ ะพะฝ ะฝะตะผะฝะพะณะพ ะฝะต ั‚ะพั‚ using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { string[] words = { "home", "programming", "victory", "C#", "football", "sport", "book", "learn", "dream", "fun" }; string letter = Console.ReadLine(); if(letter.Contains("l")) Console.WriteLine("football"); Console.WriteLine("learn"); } } }
19th May 2021, 1:15 AM
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ - avatar
0
Thank you very much
19th May 2021, 1:47 AM
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ - avatar
0
David Carroll I see you made a good ststema, but I do not even suggest how to make the second answer No match, I tried to make it using the else method, but it did not work
19th May 2021, 2:05 AM
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ - avatar
0
David Carroll If there are no matching words, the program should output "No match".
19th May 2021, 2:27 AM
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€
ะะปะตะบัะฐะฝะดั€ ะจะตั„ะตั€ - avatar