n-1位数 【字符串】

    xiaoxiao2021-03-25  113

    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<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<stack> #include<queue> #define inf 0x3f3f3f #define M 10000+10 using namespace std; int main() {   int n;scanf("%d",&n); while(n--) { char ss[10]; scanf("%s",ss); int sum=0; for(int i=1;i<strlen(ss);i++) { sum=sum*10+ss[i]-'0';    // 关键 } printf("%d\n",sum);  }  return 0;  } 

    转载请注明原文地址: https://ju.6miu.com/read-12459.html

    最新回复(0)