#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
char xias[20];
int main()
{
int t,n,eky;
cin>>t;
char *p;
while(t--)
{
memset(xias,0,sizeof(xias));
scanf("%s %d",xias,&n);
p=strchr(xias,'.');
while(n--)
p++;
if(*p==NULL)
cout<<"0"<<endl;
else
cout<<*p<<endl;
}
return 0;
}其实就是一道水题,求字符串中小数点后指定位数的数,注意一下如果位数超过字符串长度要显示0
本文介绍了一道简单的C++编程题目,要求输出字符串中小数点后指定位置的字符。若位置超出字符串长度,则输出0。涉及字符串操作及条件判断。
996

被折叠的 条评论
为什么被折叠?



