nyist 96 n-1位数

题目96
题目信息运行结果本题排行讨论区n-1位数
时间限制:3000 ms | 内存限制:65535 KB
难度:1
描述
已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。

输入
第一行为M,表示测试数据组数。
接下来M行,每行包含一个测试数据。
输出
输出M行,每行为对应行的n-1位数(忽略前缀0)。如果除了最高位外,其余位都为0,则输出0。
样例输入
4
1023
5923
923
1000样例输出
23
923
23
0

// 用字符串:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{ char s[10];
int i,n,k,m,j;
cin>>m;
while(m--)
{
cin>>s;
k=strlen(s);
for(i=1;i<k;i++)
if(s[i]!='0')break;
if(i==k){ cout<<0<<endl;continue; }

for(j=i;j<k;j++)
cout<<s[j];
cout<<endl;
}
return 0;
}


#include<stdio.h>
int main()
{
int n;
int m;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
if(m==1000000||m==100000||m==10000||m==1000||m==100||m==10)
m=0;
if(m>10&&m<100) m%=10;
else if(m<1000) m%=100;
else if(m<10000) m%=1000;
else if(m<100000) m%=10000;
else if (m<1000000) m%=100000;
printf("%d ",m);
}
return 0;
}

#include<cstdio>
int main()
{
int n,m;
scanf("%d",&n);
while(n--)

{
scanf(" %*c%d",&m); //输入的内容去掉第一位 :如果输入845,则M里面放着45
printf("%d ",m);

}
}

原文地址:https://www.cnblogs.com/2014acm/p/3901491.html