字符串处理sdut 2411
题目:http://www.sdutacm.org/sdutoj/problem.php?action=showproblem&problemid=2411
关于字符串处理的题,此题坑点很多wr了好多便,但是学到了很多的用法:
字符串有空格的输入输出,sscanf的用法等等;
还有一个浮点数精度的问题我也学到了,一个浮点型的数小于eps(1e-9)便视为零,还有sqrt函数要的精度问题
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#define eps 1e-9
using namespace std;
int main()
{
char ch;
int c=,i,t,j,n,k;
char str[][];
scanf("%d",&t);
while(t--)
{
ch='/0';
n=;
double sum1,sum2,ans,dp;
while(ch!='\n')
{
scanf("%s%c",str[n],&ch);
if(strcmp(str[n],"inches")==NULL)
k=n;
n++;
}
sscanf(str[k-],"%lf",&ans);
sscanf(str[k+],"%lf*%lf",&sum1,&sum2);把字符串
j=k+;
while(j<n)
{
int sign=strlen(str[j]);
for(i=; i<sign; i++)
{
if(str[j][i]<='Z'&&str[j][i]>='A')
str[j][i]+=;
}
j++;
}
dp=*sqrt(sum1*sum1/+sum2*sum2/);提高精度
if(ans<eps)
{
printf("Case %d: The",c++);
i=k+;
while(i < n)
{
printf(" %s", str[i]);
i++;
}
printf(" of");
for(i=; i<k-; i++)
{
printf(" %s",str[i]);
}
ans=;
printf("'s PPI is %.2lf.\n",ans);
}
else
{
printf("Case %d: The",c++);
i=k+;
while(i < n)
{
printf(" %s", str[i]);
i++;
}
printf(" of");
for(i=; i<k-; i++)
{
printf(" %s",str[i]);
}
printf("'s PPI is %.2lf.\n",dp/ans);
}
}
return ;
}
字符串处理sdut 2411的更多相关文章
- sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)
Pixel density Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...
- 串结构练习——字符串连接(SDUT 2124)
Problem Description 给定两个字符串string1和string2,将字符串string2连接在string1的后面,并将连接后的字符串输出. 连接后字符串长度不超过110. Inp ...
- SDUT 2411:Pixel density
Pixel density Time Limit: 1000MS Memory limit: 65536K 题目描述 Pixels per inch (PPI) or pixel density is ...
- sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)
n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...
- SDUT OJ 2892 A (字典树问题-输出出现次数最多的字符串的出现次数,60ms卡时间,指针+最后运行完释放内存)
A Time Limit: 60ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 给出n(1<= n && n <= 2*10^6)个字 ...
- SDUT 3035 你猜我猜不猜你猜不猜(字符串 规律性)
你猜我猜不猜你猜不猜 Time Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In the past 39th annual ACM in ...
- SDUT OJ 之 1571 《人品,有没有?》 字符串的处理问题
人品,有木有? Time Limit: 1000ms Memory limit: 32768K 有疑问?点这里^_^ 题目描述 新一届的山东理工大学ACM网络擂台赛就要开始啦!听说晋级的选手有机 ...
- sdut 2125串结构练习--字符串匹配【两种KMP算法】
串结构练习——字符串匹配 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sduto ...
- sdut 487-3279【哈希查找,sscanf ,map】
487-3279 Time Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 题目链接: sdut: http://acm.sdut.ed ...
随机推荐
- try finally 执行顺序
class Exc{ int a; int b; } public class Except { @SuppressWarnings("finally") static int c ...
- Laravel5.1 模型--ModelFactory
今天要说的是模型工厂,它是可以快速生成一些测试数据的东西,之前我们介绍过Seeder,当我们使用模型访问数据时 可以用模型工厂搭配Seeder使用. 1 编写一个ModelFactory ModelF ...
- JEECMS 2.4.2 之添加新的可扩展的ftl模版文件、自定义方法
Demo: <@cms.CfgList isPage='1' league='0' recommend='0' lala='0' hot='1' memberId='0' pageNo=page ...
- LINQ TO SQL 实现无限递归查询
from:http://blog.csdn.net/q107770540/article/list 见论坛内有网友提问类似的问题已经不止一次了, 现总结一下,希望能给以后再碰到此类问题的朋友一些帮助 ...
- 更改Scala的代码自己主动补全快捷键code completion
使用Eclipse的代码补全快捷键alt+/已经习惯了.可是IntelJIDEA中这个快捷键组合没有效果,那么我们来改动之,按ctrl+alt+s打开设置界面 之后在keymaps中选择Eclipse ...
- Android开发:《Gradle Recipes for Android》阅读笔记1.2
在android开发中会需要配置使用app的android SDK的最低版本和目标版本,这个是bulidl.gradle的android模块设置.默认有以下几个设置: applicationId,这个 ...
- unison+inotify 同步web代码并排除指定目录不同步
unison + inotify 实现web 数据双向同步 unison 是一款跨平台的文件同步对象,不仅支撑本地对本地同步,也支持通过SSH,RSH和Socket 等网络协议进行同步.unis ...
- FFF at Valentine(强连通分量缩点+拓扑排序)
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 在使用NavigationController情况下的布局的Y轴的起始位置
在有的时候,当一个ViewController被push进一个NavigationController的时候,view上会有一个高度为64的NavigationBar(除非主动隐藏了Navigatio ...
- php7/etc/php-fpm.d 配置
php7/etc/php-fpm.d/www.conf nginx php-fpm 高并发优化 - 日记本的回忆 - 博客园 https://www.cnblogs.com/cocoliu/p/856 ...