using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace random_tambah
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
int x = r.Next(10000);
Console.WriteLine(x);
string e = x.ToString();
int q=0;
for (int i = 1; i <= 4; i++)
{
string a= e.Substring((i - 1), 1);
int d=(int.Parse(a));
q=q+d;
}
Console.WriteLine(q);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace random_tambah
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
int x = r.Next(10000);
Console.WriteLine(x);
string e = x.ToString();
int q=0;
for (int i = 1; i <= 4; i++)
{
string a= e.Substring((i - 1), 1);
int d=(int.Parse(a));
q=q+d;
}
Console.WriteLine(q);
}
}
}
No comments:
Post a Comment