Перевод с паскаля на с# - C# (184702)
Формулировка задачи:
Народ помогите с паскаля перевести на С# такой код:
Program schet; var l,f,i,r:integer; begin f:=0; for i:=100 to 999 do begin r:=2; for l:=2 to i-1 do begin if i mod l <> 0 then r:=r+1; if r=i then f:=f+1; end; end; write (f); end.
Решение задачи: «Перевод с паскаля на с#»
textual
Листинг программы
using System;
namespace Test02
{
class Program
{
static int n, k;
static void Main(string[] args)
{
Console.Write("n=");
n = Convert.ToInt32(Console.ReadLine());
k = 0;
while (n>0)
{
n -= sum(n);
k = k + 1;
}
Console.Write("k=" + k);
//Console.Write(Line();
//Console.ReadKey();
}
public static int sum(int n)
{
int s = 0;
while (n>0)
{
s += n % 10;
n = n / 10;
}
return s;
}
}
}