Skip to content

[Java question][GR]

Featured Replies

esto oti exoume-> int max, cheaters, ppl

max = 11;

cheaters = 3;

ppl = max % cheaters

 

to % ti akrivos simenei re gyes?

Τελεστής - υπόλοιπο διαίρεσης

  • Author

Τελεστής - υπόλοιπο διαίρεσης

aaaaa diladi esto oti exoume 7 % 5 se int morfi....

dld pes 7/5=1 ...

8a bgalei 2 dld?

Παράδειγμα :

 

---------

 

• Ορίζουμε τρεις ακέραιες μεταβλητές a, b, c. Δίνουμε τιμές στις : a = 10 και b = 3

• Εκτελούμε την διαίρεση των αριθμών a και b με τον τελεστή % και τοποθετούμε το αποτέλεσμα στη μεταβλητή c.

• Τέλος εμφανίζουμε τα αποτελέσματα.

 

class Example {
public static void main(String args[]) {
int a = 10;
int b = 3;
int c;
System.out.println("a = " + a);
System.out.println("b = " + b);
c = a%b;
System.out.println("a % b = " + c);
}
}

Αν εκτελέσουμε το πρόγραμμα θα πάρουμε το αποτέλεσμα :

 

a = 10
b = 3
a % b = 1

  • Author

aaaaa ne re auto katavathos enoousa :P comple filos to katalava mia xara euxaristo ;)

aaaaa ne re auto katavathos enoousa :P comple filos to katalava mia xara euxaristo ;)

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.