int main()
{
int a = 0;
int b = 0;
scanf("%d%d", &a,&b);
printf("%d %d\n", a/b, a%b);
return 0;
} #include <stdio.h>
int main() {
int a, b;
scanf("%d %d",&a,&b);
int shang = a/b;
int yu = a%b;
printf("%d %d",shang,yu);
return 0;
} #include <stdio.h>
struct TEST {
int c; // 商
int d; // 余数
};
// 通过指针修改结构体,无需返回值
void chufa(int x, int y, struct TEST* result) {
result->c = x / y; // 计算商
result->d = x % y; // 计算余数
}
int main() {
int a, b;
scanf("%d %d", &a, &b);
struct TEST res;
struct TEST* P = &res;
chufa(a, b, P); // 传递结构体指针
printf("%d %d\n", res.c, res.d); // 打印商和余数
return 0;
} 结构体加指针的写法
#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;
}