字符串处理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 ...
随机推荐
- SQL Server 2008中如何为XML字段建立索引
from:http://blog.csdn.net/tjvictor/article/details/4370771 SQL Server中的XML索引分为两类:主XML 索引和辅助XML索引.其中辅 ...
- mybatis基础,mybatis配置文件核心组件typeAliases元素
typeAliases元素,术语类型别名 类型别名是为 Java 类型设置一个短的名字.它只和 XML 配置有关,存在的意义仅在于用来减少类完全限定名的冗余 <typeAliases> & ...
- MySQL没有远程连接权限设置
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; flush privileges ...
- Docker学习(1安装docker)
1.在安装之前首先查看系统版本,ubuntu centos6 7 安装方式并不相同,所以首先确定系统版本 #cat /etc/issue 确定系统版本 2.开始安装Docker (1)Ubuntu下 ...
- jQuery实现局部刷新页面数据绑定
今天遇到了一个问题:怎么样才能做到只刷新页面中的Repeater控件中的数据,在不用UploadPannel的情况下? 试了好多方法,无意间在看jquery文件时发现,使用load()方法即可解决此问 ...
- 从B 树、B+ 树、B* 树谈到R 树(转)
作者:July.weedge.Frankie.编程艺术室出品. 说明:本文从B树开始谈起,然后论述B+树.B*树,最后谈到R 树.其中B树.B+树及B*树部分由weedge完成,R 树部分由Fra ...
- Linux下查看CPU型号,内存大小,硬盘空间命令
1 查看CPU 1.1 查看CPU个数 # cat /proc/cpuinfo | grep "physical id" | uniq | wc -l 2 **uniq命令:删除重 ...
- 在windows和linux之间用SecureCRT来上传和下载文件
SecureCRT可以使用linux下的zmodem协议来快速的传送文件,使用非常方便.具体步骤:一.在使用SecureCRT上传下载之前需要给服务器安装lrzsz:A:CentOS中使用yum安装即 ...
- Insert Buffering
14.5.13.4 Insert Buffering Database applications often insert new rows in the ascending order of the ...
- 004-搭建框架-实现AOP机制【一】代理技术
前景提要 监控方法性能.执行时间.记录日志等 AOP( Aspect Oriented Programming)面向方面编程. 在AOP中,需要定义一个Aspect(切面)类来编写需要横切业务的逻辑代 ...