POJ 2871 A Simple Question of Chemistry(水~)

Description
给出一个数列,依次输出相邻两数的差值
Input
数列长度未知,每行一个浮点数,以999结束输入
Output
输出相邻两个数的差值,以End of Output结束输出
Sample Input
10.0
12.05
30.25
20
999
Sample Output
2.05
18.20
-10.25
End of Output
Solution
Code

#include<stdio.h>
int main()
{
    float n,nn;
    scanf("%f",&n);
    nn=n;
    while(1)
    {
        scanf("%f",&n);
        if((int)n==999)
        {
            printf("End of Output\n");
            return 0;
        }
        else
        {
            printf("%.2f\n",n-nn);
            nn=n;
        }
    }
}

你可能感兴趣的:(POJ 2871 A Simple Question of Chemistry(水~))