.


:




:

































 

 

 

 


. rl: 4 5 rl: 20




rl: 4 5 rl: 20

2: 8 10 2: 80

, , . "". , , .

, , . , . . .

// .

Using System;

class MyClass {

int a, b; //

// MyClass. public MyClass Factory(int i, int j) {

MyClass t = new MyClass ();

t.a = i; t.b = j;

return t; //

}

public void Show() {

Console.WriteLine(" b: " + a + " " + b);

}

}

class MakeObjects { static void Main() {

MyClass ob = new MyClass (); int i, j;

// , . for(i=0, j =10; i < 10; i++, j ) {

MyClass anotherOb = ob.Factory(i, j); // anotherOb.Show();

}

Console.WriteLine ();

}

}

.

: 0 10 : 19 : 2 8 b: 3 7 : 4 6 : 5 5 : 6 4

b: 7 3 b: 8 2 b: 9 1

. lass , , . , b . Factory () , . , b , Factory ().

Main () lass, for . , .

MyClass anotherOb = ob.Factory(i, j); //

anotherOb, , . anotherOb , , , .

C# , , . ( C# C++, .) , FindFactors () , .

// , using System; class Factor {

*

/* facts, num.

numfactors out . */ public int[] FindFactors(int num, out int numfactors) {

int[] facts = new int[80]; // 80 int i, j;

// facts. for(i=2, j=0; i < num/2 + 1; i++) if((num%i)==0) {

facts[j] = i; j++;

}

numfactors = j; return facts;

class FindFactors { static void Main() {

Factor f = new Factor(); int numfactors; inti] factors;

factors = f.FindFactors(1000, out numfactors);

Console.WriteLine(" 1000: "); for(int i=0; i < numfactors; i++)

Console.Write(factors[i] + " ");

Console.WriteLine();

}

}

.

1000:

2 4 5 8 10 20 25 40 50 100 125 200 250 500





:


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


:

:

,
==> ...

2067 - | 1892 -


© 2015-2024 lektsii.org - -

: 0.013 .