Solutions
HackerEarth
HackerEarth
  • Home
  • 👨🏻‍💻 Profile
  • Practice
    • Basic Programming
      • Input/Output
        • Easy
    • Data Structure
      • Linked List
    • Algorithms
      • Searching
        • Linear Search
        • Binary Search
      • Greedy Algorithms
Powered by GitBook
On this page
  • Life, the Universe, and Everything
  • Zoos

Was this helpful?

  1. Practice
  2. Basic Programming
  3. Input/Output

Easy

Life, the Universe, and Everything

using System;
					
public class Program
{
	public static void Main()
	{
        while(true){
            int num = int.Parse(Console.ReadLine());
	        if(num==42)
	            break;
	        else
                Console.WriteLine(num);
        }	
    }
}

Zoos

using System;
					
public class Program
{
	public static void Main()
	{
		string word = Console.ReadLine();
		int zCount = 0, oCount = 0;
		for (int i = 0; i < word.Length; i++){
			if(word[i] == 'z')
				zCount++;
			else
				oCount++;
		}
		if(2 * zCount == oCount)
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}
}
PreviousInput/OutputNextData Structure

Last updated 2 years ago

Was this helpful?