1254:n-1位数

来源:互联网 发布:淘宝配眼镜靠谱吗 知乎 编辑:程序博客网 时间:2024/06/07 11:07

1254:n-1位数


Description


已知W是一个大于10但不大于1000000的无符号整数,若w是n(n>=2)位的整数,则求出w的后n-1位的数。


Input


第一行为M,表示测试数据组数。

接下来M行,每行包含一个测试数据。


OUtput


输出M行,每行对应行的n-1位数(忽略前缀0)。如果除了最高位外,其余位都为0,则输出0.


Sample Input


4

1023

5923

923

1000


Sample Output


23

923

23

0


#include<iostream>using namespace std;int main(){    int M,n,flag,temp,i,first;    char a[100];    cin>>M;    while(M--)    {        flag=first=1;        i=0;        cin>>n;        while(n!=0)        {            temp=n%10;            a[i++]=temp+'0';            n=n/10;        }        a[i-1]='\0';        for(i-=2;i>=0;)        {            if(first&&a[i]=='0')                i--;            else            {                first=0;               cout<<a[i];               i--;               flag=0;            }        }        if(flag)            cout<<"0";        cout<<endl;    }    return 0;}