1) 87e5x34t = 87 * 5 * 34 =14790
2) 74582ex0e5 = 74582*0*5 = 0
3)74582ex05e5 = 1864550 (05 in yazımı hatalı)
4)12ex420k5i7 = 72*420*5*7 = 176400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace paralel1
{
class Program
{
static void Main(string[] args)
{
string asd = "87e5x34t";
List list = new List();
Console.WriteLine("Sonuc : {0}", StringKatsayi(asd,list));
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine(String.Format("{0} .ci deger : {1}", i + 1, list[i]));
}
Console.ReadKey();
}
static int StringKatsayi(string yazi,List liste)
{
int anatoplam = 1;
int toplam = 0;
int katsayi = 1;
int tmp = 1;
char cr;
bool gordumu = false;
for (int i = yazi.Length - 1; i >= 0; i--)
{
cr = yazi[i];
if (cr > 47 && cr < 58)
{
tmp = cr - 48;
toplam += katsayi * tmp;
katsayi *= 10;
gordumu = true;
}
else
{
if (gordumu == true)
{
liste.Add(toplam);
katsayi = 1;
toplam = 0;
gordumu = false;
}
}
}
if (gordumu == true)
liste.Add(toplam);
for (int i = 0; i < liste.Count; i++)
{
anatoplam *= liste[i];
}
return anatoplam;
}
}
}
Hiç yorum yok:
Yorum Gönder