首页 > 其他 > 详细

poj2871

时间:2015-06-18 13:19:18      阅读:75      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!