码迷,mamicode.com
首页 > 其他好文 > 详细

poj2871

时间:2015-06-18 13:22:11      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
#include <stdio.h>
#include <stdlib.h>
//法一
int main()
{
    double temar[10000];
    int i=0,tmp;
    while(1)
    {
        scanf("%lf",&temar[i]);
        if(temar[i] == 999)
            break;
        i++;
    }
    tmp=i-1;
    for(i=1; i<=tmp; i++)
    {
        printf("%.2f\n",temar[i]-temar[i-1]);
    }
    printf("End of Output");
    return 0;
}
//法二
scanf("%lf",&last);
while(1)
{
    scanf("%lf",&now);
    if(now == 999)
        break;
    printf("%.2f",now-last);
    last=now;
}
View Code

 没必要用数组

poj2871

标签:

原文地址:http://www.cnblogs.com/gabygoole/p/4585468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!