ესეც იგივე დავალება C#-ში.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void myint()
{
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0}", x);
Console.WriteLine("{0}", y);
if (x < y)
{
for (int i = x; i <= y; i++)
Console.WriteLine("counting from {0} to {1}: {2}", x, y, i);
}
else
{
for (int i = y; i <= x; i++)
Console.WriteLine("counting from {0} to {1}: {2}", y, x, i);
}
}
static void myString()
{
{
string s = Console.ReadLine();
char c = Convert.ToChar(Console.ReadLine());
Console.WriteLine("{0}", s);
Console.WriteLine("{0}", c);
int counter = 0;
for (int i = 0; i < s.Length; i++)
{
if (s == c)
{
counter++;
}
}
Console.WriteLine("'{0}' symbol was used {1} times in the word.", c, counter);
}
}
static void Main(string[] args)
{
Console.WriteLine("Enter two numbers");
myint();
Console.WriteLine("Enter a word and a letter:");
myString();
Console.ReadKey();
}
}
}
ესეც კომპილაციის შედეგი:
როგორ მოგწონთ? გავს თუ არა?
ჯამპერ კიდე დადე დავალებები მე C#-ში დავწერ ხოლმე