c# - What are the semantics of the modulus operator? -
Programmer 2010 was a piece of code in C #, which I was thinking, here it is: I think counting arrays have a slot in memory, and this is putting new card suits and faces in the deck and they return the counting amount. I do not understand how you can divide into the measure and zero? Or am I mistaken? Thank you The question seems to be that the modulus operator is confusing you. The modulus ( An example is You can use it like this: (int i = 0; i & lt; deck langti; i ++) {deck [i] = new card (face [i% 13], suite [i / 13]) ; }
% ) operator calculates the balance from a split. It is structured in the form of division (fraction / separator). It appears that you are wrong with
i% 13 as
the remaining 13 / i looks like this. This is
remaining I / 13 so if
i is zero, then the modulus operator will return 0. You ever
3/2 .
3/2 is 1 and half but if you do not save that result for integer (no decimals), then only
1 is saved where the half went? It was thrown away if you want it, you can save it as
float or
double or use the modulus operator.
3% 2 will give you
1 , the rest here is an example program:
Straight ModuleShelper {public integer; Public int balance; Public ModulesShelper (Int Numerator, Intestinal) {Causality = fraction / bottom; Balance = fraction% character; }}
class program {static zero main (string [] args) {moduleshelper mod = new Moduleshelper (args [0], args [1]); Console.light line ("quotient: {0}", mod.Quotient); Console.light line ("balance: {0}", mod.Remainder); Console.ReadKey (); // batch `pause`}}
Comments
Post a Comment