已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。
4 1023 5923 923 1000
23 923 23 0
代码如下:
#include <cstdlib> #include <cstring> #include <algorithm> #include <cstdio> #include <cmath> #include <iostream> #include <vector> #include<set> #include<queue> using namespace std; typedef long long ll; int main() { int t,flag; char str[7]; cin>>t; while(t--) { cin>>str; flag=0; // 标记除去前缀0的情况 int len=strlen(str); queue<int>q; for(int i=1;i<len;i++) { q.push(str[i]); } int j=0; // 标记全为0的情况 while(!q.empty()) { if(q.front()!=‘0‘ || flag) {cout<<q.front()-‘0‘; flag=1; j++;} q.pop(); } if(j==0) cout<<0<<endl; else puts(""); } return 0; }
原文:http://www.cnblogs.com/zn505119020/p/3619663.html