.


:




:

































 

 

 

 


, .




' : AreaPerPerson () , . , , AreaPerPerson (). ,

areaPP = house.AreaPerPerson ();

areaPP ( house).

, AreaPerPerson () int. , . , , , , , , . , double, double.

, , , . , areaPP, AreaPerPerson () , WriteLine (), .

Console.WriteLine(" :\ " +

house.Floors + " \ " + house.Occupants + " \ " + house.Area +

" . , \ " + house.AreaPerPerson() +

" ");

, WriteLine (), house. AreaPerPerson (), WriteLine(). , AreaPerPerson () , Building. , .

if(.AreaPerPerson() > 2.AreaPerPerson())

Console.WriteLine(" ");

. , , . , , , . . , . . , , .

, . ChkNum Is Prime (), true, , . false. , IsPrimeO bool.

// .

Using System;

class ChkNum {

// true, // , public bool IsPrime(int ) { if ( <= 1) return false;.

for (int i=2; i <= x/i; i++) if ((x %i) == 0) return false;

Return true;

}

}

class ParmDemo {

static void Main() {

ChkNum ob = new ChkNum();

for (int i=2; i < 10; i++)

if(ob.IsPrime(i)) Console.WriteLine(i + " ."); else Console.WriteLine(i + " .");

}

}

.

.

.

.

.

.

.

.

.

IsPrime () , . . , Is Prime (). . Is Prime () , 2. , Is Prime () , 2. 3, 4 .. , , Is Prime () , , .

, . , . ChkNum, LeastComFactor (), . , , .

// , .

Using System;

class ChkNum {

// true, // , public bool IsPrime(int ) { if( <= 1) return false;

for (int i=2; i <= x/i; i++) if((x %i) == 0) return false;

Return true;

}

// , public int LeastComFactor(int a, int b) { int max;

if(IsPrime(a) || IsPrime(b)) return 1;

max = a < b? a: b;

for (int i=2; i <= max/2; i++)

if(((a%i) == 0) && ((b%i) == 0)) return i; return 1;

}

}

class ParmDemo {

static void Main() {

ChkNum ob = new ChkNum(); int a, b;

for (int i=2; i < 10; i++)

if(ob.IsPrime(i)) Console.WriteLine(i + ."); else Console.WriteLine(i + " .");

= 7; b = 8;

Console.WriteLine(" " + + " " + b + " " + ob.LeastComFactor(, ));

= 100;

= 8;

Console.WriteLine(" " + + " " + b + " " + ob.LeastComFactor(, ));

= 100;

= 75;

Console.WriteLine(" " + + " " + b + " " + ob.LeastComFactor(, ));

}

}

: LeastComFactor (), . .

.

.

.

.

.

.

.

.

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

2

 

 

 

 

 

 

 

5

 





:


: 2016-12-03; !; : 446 |


:

:

, .
==> ...

1567 - | 1342 -


© 2015-2024 lektsii.org - -

: 0.015 .