HRBUST——1800 元芳,你怎麼看
阿新 • • 發佈:2018-12-28
簡單的數學題,需要注意的是如何進行判斷
這裡我們先宣告四個變數:
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;
}