sdut2411 Pixel density
来源:互联网 发布:苹果激活策略查询软件 编辑:程序博客网 时间:2024/05/16 16:56
Pixel density
Time Limit: 1000MS Memory limit: 65536K
题目描述
Pixels per inch (PPI) or pixel density is a measurement of the resolution of devices in various contexts; typically computer displays, image scanners, and digital camera image sensors. Note, the unit is not square inches. Good quality photographs usually require 300 pixels per inch when printed. When the PPI is more than 300(phone), we call it retina screen. Sunnypiggy like the retina screen very much.
But you know it is expensive for Sunnypiggy and Sunnypiggy’s own smart phone isn’t like that.
I tell you how to calculate the PPI. First we must know how big the mobile phone’s screen is. Then we get the resolution (Hp*Wp) about it. After that we calculate the diagonal resolution in pixels (Dp) and divided by diagonal size in inches. Now you get the answer.
Maybe you knew it, but Sunnypiggy’s math is very bad and he wants you to help him to calculate the pixel density of all the electronic products he dreamed.
输入
First you will get an integer T which means the number of test cases, and then Sunnypiggy will tell you the name and type of the electronic products. And you know, Sunnypiggy is a careless boy and some data aren’t standard, just like 04.00 inches or 0800*0480.
输出
Output the answers to Sunnypiggy just like the sample output. Maybe it is not a phone. Sunnypiggy like such a form, although it seems no use. The result should be rounded to 2 decimal places. When it has no screen (0.0 inches) that we define the answer is 0.00(PPI).
示例输入
2iPhone 4S 3.5 inches 960*640 PHONEThe new iPad 0009.7 inches 2048*1536 PAD
示例输出
Case 1: The phone of iPhone 4S's PPI is 329.65.Case 2: The pad of The new iPad's PPI is 263.92.
提示
Wp is width resolution in pixels, Hp is height resolution in pixels.
来源
示例程序
/***坑很多,1.inches的值可能为0,那样就不能除了2.把大写变小写的话,需要判断它确实为大写3.反正是字符串的处理小心点就行了***///#include<cstring>#include<iostream>#include<cstdio>#include<cmath>#include<string.h>#include<stdio.h>using namespace std;int main(){ int t,kase=0; cin>>t; while(t--) { getchar(); char c,s[100][50]; int k=0; while(1) { cin>>s[k]; if( strcmp(s[k],"inches")==0 ) break; k++; } double inches; sscanf(s[k-1],"%lf",&inches);// printf("inches==%lf\n",inches); getchar(); double Wp,Hp; scanf("%lf*%lf",&Wp,&Hp); char str[100]; scanf("%s",str); printf("Case %d: The ",++kase); for(int i=0;i<strlen(str);i++) { if(str[i]>='A' && str[i]<='Z') printf("%c",str[i]+32); else printf("%c",str[i]); } printf(" of"); for(int i=0;i<k-1;i++) cout<<" " <<s[i]; printf("'s PPI is "); if(inches == 0) printf("0.00.\n"); else printf("%.2lf.\n", sqrt(Wp*Wp+Hp*Hp ) / inches ); } return 0;}
- sdut2411 Pixel density
- Sdut2411 Pixel density 山东省第三届ACM省赛(输入输出字符串处理)
- SDUT Pixel density
- hdu Pixel density 2411
- SDUT:2411 Pixel density
- SDUT 2411:Pixel density
- DisplayMatrix.density & DisplayMatrix.densityDpi & pixel
- UI 设计:pixel dip dpi sp density
- Pixel density(简单的字符串处理)
- 山东省第三届省赛 (Pixel density)
- SDUT 2411 Pixel density(模拟,字符串)
- 第三届山东ACM省赛 Pixel density
- Android中不同Density下Pixel dip关系探究
- 【模拟细节毕业题】SDUT 2411——Pixel density
- 设备独立像素(density)与像素(pixel)
- 设备独立像素(density)与像素(pixel)
- 2013山东省第三届ACM省赛 Pixel density
- 关于android多分辨率中的density和density-independent pixel的区别
- 关节点(atriculation point)算法
- float,double数据类型在内存中的存储方式
- XML的读取和解析以及输出
- LSWM处理时,网络中断,出现错误
- 科学方法论--信息论、老鼠毒药问题、称球问题(全文)
- sdut2411 Pixel density
- Oracle数据库生成主键
- 第五周 程序阅读
- MFC改变编辑框背景、字体、颜色等
- Android 如何进行简单的反编译
- python 如何判断一个array是否是空?
- C语言五大内存分区介绍
- 数据挖掘、C#与Matlab混合编程链接
- Java的运行原理