Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to integer and remainder in C language?
How to integer and remainder in C language?
C language rounding and remainder:

example

Public class Demo _ 1 {undefined.

Public static void main (string parameter) {undefined

Scanner sc = new scanner (system input)

System.out.print ("Please enter the number to be judged (five digits):")

int num = sc.nextInt()

sc.close()

//Truncate the last digit

int a = num % 10

//Intercept the first number

int b = num / 10000

//Intercept the fourth digit

int c = num % 100 / 10

//Intercept the second digit

int d = num / 1000 % 10

System.out.println(a +","+ b +","+ c +","+ d)

Boolean type b 1 = (a == b)

Boolean b2 = (c == d)

if(b 1 & amp; & B2) {Not defined

System.out.println(num+ "is palindrome")

} else {undefined

System.out.println(num+ "non-palindrome")

}

}

}

1. Assign directly to integer variables.

Int i = 3.5 or i = (int) 3.5.

This method uses rounded decimal parts.

2, integer division operator "/"rounding

/'itself has an integer function (int/int), but the integer division result of negative numbers is related to the C compiler used.