hdu 1597 find the nth digit

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1597

//用C++交能过,G++交就不能过,不知道为什么
#include
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,i=1;
        scanf("%d",&n);
        while(n>i)
        {
            n-=i;
            i++;
        }
        n=n%9;
        if(n) printf("%d\n",n);
        else printf("9\n");
    }

    return 0;
}


你可能感兴趣的:(hdu 1597 find the nth digit)