版权声明:fromZjy QQ1045152332 https://blog.csdn.net/qq_36762677/article/details/82941334
1.反转数
123=321
-123=-321
100=1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int j=0;
while (n!=0){
j=j*10+n%10;
n/=10;
}
System.out.println(j);
}
}
2.整数求和
给定整数n,取若干个1到n的整数可求和等于整数m,编程求出所有组合的个数。比如当n=6,m=8时,有四种组合:[2,6], [3,5], [1,2,5], [1,3,4]。限定n和m小于120