POJ3077 Rounders

四舍五入的思想方法,一直处理到只剩下整十,整百,整千。。。。。



#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n, a, i, j, ten, tmp;
    scanf("%d",&n);
    while(n--)
    {
        ten=1;
        scanf("%d",&a);
        while(a>10)
        {
            tmp=a%10;
            a/=10;
            if(tmp>=5)
                a++;
            ten*=10;
        }
        printf("%d\n",a*ten);
    }
    return 0;
}


posted @ 2013-08-15 20:39  Ink_syk  阅读(100)  评论(0编辑  收藏  举报