简单的数学题,需要注意的是如何进行判断
这里我们先声明四个变量:
x,y,i,j是题目要求的输入
people是强盗人数,money是银两数量
过程不累述
关键点在于,判断强盗说的话是否为真
这里用了两个变量zs和zs2
用来判断people和money是否为整数
同时不要忘记people和money是正数
AC代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//AC万岁 ( ง ' - ' ) ง 加油
int main()
{
double x,y,i,j;
double people,money;
while(scanf("%lf%lf%lf%lf",&x,&y,&i,&j)!=EOF)
{
people=0;
money=0;
people=(y+j)/(i-x);
money=people*i-j;
int zs=people;
int zs2=money;
if(zs==people && zs2==money && people>0 && money>0)
printf("He is right\n");
else
printf("Back to the adult, it surely has something\n") ;
}
return 0;
}