题目: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的更多相关文章

  1. sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)

    Pixel density Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...

  2. 串结构练习——字符串连接(SDUT 2124)

    Problem Description 给定两个字符串string1和string2,将字符串string2连接在string1的后面,并将连接后的字符串输出. 连接后字符串长度不超过110. Inp ...

  3. SDUT 2411:Pixel density

    Pixel density Time Limit: 1000MS Memory limit: 65536K 题目描述 Pixels per inch (PPI) or pixel density is ...

  4. sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

    n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...

  5. SDUT OJ 2892 A (字典树问题-输出出现次数最多的字符串的出现次数,60ms卡时间,指针+最后运行完释放内存)

    A Time Limit: 60ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 给出n(1<= n && n <= 2*10^6)个字 ...

  6. SDUT 3035 你猜我猜不猜你猜不猜(字符串 规律性)

    你猜我猜不猜你猜不猜 Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 In the past 39th annual ACM in ...

  7. SDUT OJ 之 1571 《人品,有没有?》 字符串的处理问题

    人品,有木有? Time Limit: 1000ms   Memory limit: 32768K  有疑问?点这里^_^ 题目描述 新一届的山东理工大学ACM网络擂台赛就要开始啦!听说晋级的选手有机 ...

  8. sdut 2125串结构练习--字符串匹配【两种KMP算法】

    串结构练习——字符串匹配 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sduto ...

  9. sdut 487-3279【哈希查找,sscanf ,map】

    487-3279 Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 题目链接: sdut:   http://acm.sdut.ed ...

随机推荐

  1. 数组中binarySearch 中小小的误区! 用的时候大家要注意点

  2. Introduction to Mathematical Thinking - Week 6 - Proofs with Quantifieers

    Mthod of proof by cases 证明完所有的条件分支,然后得出结论. 证明任意 使用任意 注意,对于一个任意的东西,你不知道它的具体信息.比如对于任意正数,你不知道它是 1 还是 2等 ...

  3. SqlCommand对象-Transaction事务的使用

    using (SqlConnection connection = new SqlConnection(connStr)) { SqlCommand sqlcmd = new SqlCommand() ...

  4. 网络安装CentOS6.4

    第一步:所需工具安装包下载地址: http://115.com/file/antbtamu#网络安装CentOS.rar(或者下载NetbootM.exe和hfs.exe) 第二步:将CentOS6. ...

  5. MySQL版本升级5.6到5.7版本

    从5.6升级到5.7版本,5.7的版本为5.7.17 升级的过程还是比较简单,需要注意几个点 1.下载对应的包 2.备份整个数据库 3.使用升级参数 1.下载 # wget "https:/ ...

  6. Python3.6全栈开发实例[005]

    5.接收两个数字参数,返回比较大的那个数字. def compare(a,b): return a if a > b else b # 三元表达式 print(compare(20,100))

  7. nodejs koa2 获取get值和post值,提交表单

    // 获取get值 router.get('/b', async(ctx, next) => { ctx.state = { title: 'Koa2', name: '小明-list' } l ...

  8. Ubuntu 14.04上安装WineTMQQ2013麒麟版

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/tao_627/article/details/24187699 我先后试用了longterm团队的2 ...

  9. CentOS Linux中zip压缩和unzip解压缩命令详解

    以下命令均在/home目录下操作cd /home  #进入/home目录1.把/home目录下面的mydata目录压缩为mydata.zip     zip -r  mydata.zip   myda ...

  10. 我的第二个Python小程序

    输出0-100之间的偶数: # Author: fansik # Description: Output an even number between 0 and 100 # method one n ...