Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.WriteLine("Enter a sentence: ");
- string sentence = Console.ReadLine();
- Console.Write("Enter a word: ");
- string word = Console.ReadLine();
- int counter = 0;
- int counterWord = 0;
- for(int i = 0; i < sentence.Length; i++)
- {
- if (sentence[i] == ' ')
- {
- counterWord = 0;
- continue;
- }
- else if(sentence[i] == word[counterWord])
- {
- counter++;
- }
- else
- {
- counterWord = 0;
- }
- counterWord++;
- }
- if(counter == word.Length)
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement