#include<stdio.h> int main(void){ int a, b; scanf("%d %d", &a, &b); if(b != 0) printf("%d %d\n", a/b, a%b); else printf("除数为0,Error"); return 0; }
//计算两个整数的商和余数 // #include<stdio.h> int main() { int a = 0; int b = 0; int c = 0; int d = 0; scanf("%d %d",&a, &b);//读入数据 //判断a和b的大小,让a的值始终较大 if(a < b) { c = a; a = b; b = c; } c = a/b; //计算商 c = (int)c; //把商转换成整数 d = a%b; //计算余数 printf("%d",c); printf(" "); //题目要求有空格 printf("%d",d); return 0; }
while(l=readline()){ var arr=l.split(" "); var a=arr[0]; var b=arr[1]; console.log(parseInt(a/b)+" "+a%b); }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); String[] ss = s.split(" "); int a = Integer.parseInt(ss[0]); int b = Integer.parseInt(ss[1]); System.out.printf("%d %d",a/b,a%b); } }
#include <stdio.h> int main() { int a = 0; int b = 0; int c = 0; int d = 0; scanf("%d %d", &a, &b); if(a > 0 && b < 10000) { c = a / b; d = a % b; printf("%d %d ",c ,d); } return 0; }