Csharp/C Sharp/Language Basics/Mod — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Demonstrate the % operator
/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate the % operator.
using System;
public class ModDemo {
public static void Main() {
int iresult, irem;
double dresult, drem;
iresult = 10 / 3;
irem = 10 % 3;
dresult = 10.0 / 3.0;
drem = 10.0 % 3.0;
Console.WriteLine("Result and remainder of 10 / 3: " +
iresult + " " + irem);
Console.WriteLine("Result and remainder of 10.0 / 3.0: " +
dresult + " " + drem);
}
}
Mod test
/*
Learning C#
by Jesse Liberty
Publisher: O"Reilly
ISBN: 0596003765
*/
using System;
public class ModTester
{
public static int Main()
{
for (int counter=1; counter<=100; counter++)
{
Console.Write("{0} ", counter);
if ( counter % 10 == 0 )
{
Console.WriteLine("\t{0}", counter);
}
}
return 0;
}
}