Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp20
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool[] osumat = new bool[5];
- kysyOsumat(osumat);
- }
- static void kysyOsumat(bool [] pOsumat)
- {
- for (int i =0; i < pOsumat.Length; i++)
- {
- Console.Write("Osuiko laukaus " + (i + 1) + " (1=osui, 0=ohi) :");
- string syote = Console.ReadLine();
- int syoteInt = Convert.ToInt32(syote);
- if (syoteInt == 1)
- {
- pOsumat[i] = true;
- }
- else
- {
- pOsumat[i] = false;
- }
- }
- }
- static void TulostaOsumat(bool[] pOsumat)
- {
- int osumienLukumaara = 0;
- for (int i = 0; i < pOsumat.Length; i++)
- {
- if (pOsumat[i])
- {
- osumienLukumaara++;
- }
- }
- Console.WriteLine("Osumien lukumäärä on " + osumienLukumaara +
- " ja huteja tuli " + (pOsumat.Length - osumienLukumaara));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement