Dasturning blok sxemadagi algoritmi: Dasturning C# dagi ko’rinishi: using


Download 66.85 Kb.
bet1/4
Sana20.11.2023
Hajmi66.85 Kb.
#1790164
  1   2   3   4
Bog'liq
3-topshiriq 2-variant


Fan: Algoritmik tillar va dasturlash Guruh 22.11 2022-2023-o’quv yili

1. 100-999 gacha oraliqdagi sonlarni so’zlarda ifodalovchi dastur tuzilsin.
(masalan, 123-“bir yuz yigirma uch”)
Dasturning blok sxemadagi algoritmi:
Dasturning C# dagi ko’rinishi:
using System;

namespace ahmadali
{
class Program
{
public static void Main(string[] args)
{
int a,k,b; string s;
Console.Write("100-999 oraliqdagi masala sonini kiriting: ");
a=int.Parse(Console.ReadLine());
if (a<=999)
{
k=a/100; b=(a%100)/10;a=a%10;s="";
switch (k)
{
case 0: s=""; break;
case 1: s="bir yuz ";break;
case 2: s="ikki yuz "; break;
case 3: s="uch yuz "; break;
case 4: s="to'rt yuz "; break;
case 5: s="besh yuz "; break;
case 6: s="olti yuz "; break;
case 7: s="yetti yuz ";break;
case 8: s="sakkiz yuz ";break;
case 9: s="to'qqiz yuz "; break;
default: Console.Write("Xato kiritdingiz.");break;
}
switch (b)
{
case 0: s+=""; break;
case 1: s+="o'n ";break;
case 2: s+="yigirma "; break;
case 3: s+="o'ttiz "; break;
case 4: s+="qirq "; break;
case 5: s+="ellik "; break;
case 6: s+="oltmish "; break;
case 7: s+="yetmish ";break;
case 8: s+="sakson ";break;
case 9: s+="to'qson "; break;
default: Console.Write("Xato kiritdingiz.");break;
}
switch (a)
{
case 0: s+=""; break;
case 1: s+="bir ";break;
case 2: s+="ikki "; break;
case 3: s+="uch "; break;
case 4: s+="to'rt "; break;

Download 66.85 Kb.

Do'stlaringiz bilan baham:
  1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling