Advertisement
BloodMoonYTC

szavakszama

Oct 24th, 2021 (edited)
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace szavakszama
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool elso;
  10.             int i, k;
  11.             string sz1;
  12.  
  13.             Console.Write("Ird be a szoveget: ");
  14.             sz1 = Console.ReadLine();
  15.  
  16.             for(elso = true, i = 0, k = 0; i < sz1.Length; i++)
  17.             {
  18.                 if (sz1[i]!=' ')
  19.                 {
  20.                     if (elso)
  21.                     {
  22.                         k++; elso = false;
  23.                     }
  24.                 }
  25.                 else
  26.                     elso = true;
  27.             }
  28.  
  29.             Console.WriteLine("A szavak száma: " + k);
  30.             Console.WriteLine("Kólity Kristóf");
  31.             Console.ReadLine();
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement