nyoj 96 n-1位数(处理前导 0 的情况)(string)
n-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 C代码:#include <cstdio>
#include <cstring> int main(){
int i, j, n;
char a[];
scanf("%d", &n);
while(n--){
scanf("%s", a);
int len = strlen(a);
for(i = ; i < len; i++){
if(a[i] != '')
break;
}
if(i < len)
for(j = i; j < len; j++)
printf("%c", a[j]);
else
printf("");
printf("\n");
}
return ;
}C++代码
#include <iostream>
#include <string>
using namespace std; int main(){
int n, len, i;
string s;
cin >> n;
while(n--){
cin >> s;
len = s.length(); for(i = ; i < len; i++)
if(s[i] != '')
break; if(i == len){
cout << '' << endl;
continue;
} for(int j = i; j < len; j++)
cout << s[j];
cout << endl;
}
return ;
}
nyoj 96 n-1位数(处理前导 0 的情况)(string)的更多相关文章
- nyoj 96 n-1位数(处理前导 0 的情况)
n-1位数 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描述 已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则 ...
- php导出CSV时,超长数字精度丢失问题与前导0的字符串丢失0的问题解决
php生成的CSV有时候会遇到两个特殊情况: 1.输出的字段中,含有超长数字(18位的数字)比方身份证:122121197410180016,就算输出时字段加上"",还是会被识别成 ...
- 阶乘之和 输入n,计算S=1!+2!+3!+…+n!的末6位(不含前导0)。n≤10 6 ,n!表示 前n个正整数之积。
阶乘之和输入n,计算S=1!+2!+3!+…+n!的末6位(不含前导0).n≤10 6 ,n!表示前n个正整数之积.样例输入:10样例输出: package demo; import java.uti ...
- php 如何得到不含前导0的时分秒
通常我们获取时分秒是用 date("H:i:s") ,得到的效果是这样的 而如果想获取不含前导0的时分秒的话,就需要把前导0去掉. 如何去掉呢?我们来分析一下,07变7,20还是2 ...
- HDU1800 hash+去前导0
注意一:卡map的时间,但是好好写+运气还是可以卡过,哇...求人品爆发 注意二:去前导0,毕竟‘0’也有ASCII码 #include<cstdio> #include<cstdl ...
- python tricks —— datetime 删除日期中的前导 0
>> from datetime import datetime >> now = datetime.now() >> now.strftime('%Y-%m-%d ...
- [poj 3252]数位dp前导0的处理
通过这个题对于数位dp中前导0的处理有了新的认识. 题目链接:http://poj.org/problem?id=3252 //http://poj.org/problem?id=3252 #incl ...
- malloc()参数为0的情况
问题来自于<程序员面试宝典(第三版)>第12.2节问题9(这里不评价<程序员面试宝典>,就题论题): 下面的代码片段输出是什么?为什么? char *ptr; ))==NULL ...
- Swift2.0 中的String(三):类型转换
本系列第三篇,String相关的类型转换.其他的几篇传送门(GitHub打不开链接的同学请自行把地址github改成gitcafe,或者直接去归档里找:-P): Swift2.0 中的String(一 ...
随机推荐
- 51nod 1116 K进制下的大数
你万万想不到,Long Long 就能存下的数据 #include <iostream> #include <cstdio> #include <cstdlib> ...
- CodeForces 923C Perfect Security
C. Perfect Security time limit per test3.5 seconds memory limit per test512 megabytes inputstandard ...
- 1354 选数字 DP背包 + 数学剪枝
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1354&judgeId=187448 其实这题和在若干个数字中,选 ...
- 原生开发之css样式问题(持续更新)
·移动端开发将div高度设置为设备高度 div{ Height:100vh; } · select选择器文字设置: /*select文字右对齐*/ select{ direction: rtl; } ...
- spark性能优化(包括优化原理及基本方法)
https://www.jianshu.com/p/b8841a8925fb spark性能优化 1.诊断内存的消耗 2. 高性能序列化类库 3. 优化数据结构 4. 对多次使用的rdd进行持久化或者 ...
- linux下php开启pdo扩展
前提:网页报错 为解决问题:Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' 解决方案 : 下载安装PHP_MYSQL扩展 wget http:// ...
- 【PostgreSQL-9.6.3】Red Hat 4.4.7下的安装
1. 下载源码包https://www.postgresql.org/ftp/source/v9.6.1/ 2. 上传到/opt目录下 3. 创建postgres用户及dba组,并修改压缩包的属主属组 ...
- vuex的应用和解决的实际问题
这是vuex的语法结构内容 简单的理解vuex: new Vue({ // state data () { return { count: 0 } }, // view template: ` < ...
- OpenCV3.3安装教程
http://blog.csdn.net/amusi1994/article/details/76768775?locationNum=10&fps=1
- leetcode_894. All Possible Full Binary Trees
https://leetcode.com/problems/all-possible-full-binary-trees/ 给定节点个数,求所有可能二叉树,该二叉树所有节点要么有0个子节点要么有两个子 ...