计算概论(A)/基础编程练习2(8题)/5:点和正方形的关系
#include<stdio.h>
#include<math.h>
int main() {
// 输入坐标
float x, y;
while(scanf("%f %f", &x, &y) != EOF) {
// 计算坐标点与原点的欧氏距离
float dist=sqrt(x*x+y*y); /*
// 简单判断横坐标和纵坐标的截距abs(x)、abs(y)和与原点距离dist 注意:abs(1.0*x)无效 结果为0.000000
if(1.0*abs(x)>1.0 || 1.0*abs(y)>1.0 || dist>sqrt(2.0)) {
printf("no\n");
} else
printf("yes\n");
*/ // 简单判断横坐标和纵坐标的截距和与原点距离
if(x>1.0 || y>1.0 || dis>sqrt(2.0)) {
printf("no\n");
} else
printf("yes\n");
}
// 运行中 Ctrl+z+回车 即可退出
return ;
}
/*
pkuic_1856.c
计算概论(A)/基础编程练习2(8题)/5:点和正方形的关系
http://pkuic.openjudge.cn/base2/5/
5:点和正方形的关系
查看 提交 统计 提问
总时间限制: 1000ms 内存限制: 65536kB
描述
有一个正方形,四个角的坐标(x,y)分别是(1,-1),(1,1),(-1,-1),(-1,1),x是横轴,y是纵轴。写一个程序,判断一个给定的点是否在这个正方形内。
输入
输入坐标x,y
输出
yes或者no
样例输入
3 4
1 1
0 0
样例输出
no
yes
yes
提示
提示1:
系统的测试文件中数据有很多组,因此同学们在程序里要写循环读取数据并判断是否读完文件的代码。
如果不知道如何处理,可以参考下面的两个模板:
C++这样写:
while(cin>>x>>y)
{
判断x,y是否在正方形里的代码
} C这样写:
while(scanf(%x %y",&x,&y)!=EOF)
{
判断x,y是否在正方形里的代码
} 提示2:
输出结果时,必须加上换行符endl(C++语言)或\n(c语言)。不然会报输出格式错误。 提示3:
要选对编程语言。如果程序是用C++语法写的,就不能在language里选c。会报编译错误。 例子:
比如说编号为1000的练习题,按以上要求的格式写出来的标准答案如下:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<< a+b << endl;
}
return 0;
}
*/
计算概论(A)/基础编程练习2(8题)/5:点和正方形的关系的更多相关文章
- 计算概论(A)/基础编程练习2(8题)/8:1的个数
#include<stdio.h> int main() { ; // 存储测试数据的二进制形式中1的个数 int bian[N]; // 输入十进制整数N 表示N行测试数据 scanf( ...
- 计算概论(A)/基础编程练习2(8题)/7:整数的个数
#include<stdio.h> int main() { ] = {}; // 输入k个正整数 scanf("%d",&k); // 循环读入和进行算术 w ...
- 计算概论(A)/基础编程练习2(8题)/6:数组逆序重放
#include<stdio.h> int main() { // 输入n个整数 ; scanf("%d", &n); // 循环读入元素 while(scan ...
- 计算概论(A)/基础编程练习1(8题)/2:苹果和虫子
#include<stdio.h> #include<math.h> int main() { /* n个苹果 每x小时能吃掉一个苹果 经过y小时 */ float n, x, ...
- 计算概论(A)/基础编程练习1(8题)/1:大象喝水
#include<stdio.h> int main() { ; // n < 100 scanf("%d", &n); // 循环遍历判断 再进行平方和 ...
- 计算概论(A)/基础编程练习2(8题)/4:骑车与走路
#include<stdio.h> int main() { // 待处理的数据数量n ; scanf("%d", &n); float meters[n]; ...
- 计算概论(A)/基础编程练习2(8题)/3:计算三角形面积
#include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, ...
- 计算概论(A)/基础编程练习2(8题)/2:计算书费
#include<stdio.h> int main() { // 声明与初始化 ; // k组测试数据的总费用 double s[k]; // 单价表 double price[]= { ...
- 计算概论(A)/基础编程练习2(8题)/1:求平均年龄
#include<stdio.h> int main() { // 声明与初始化 , s=, age=; // 输入学生人数 scanf("%d", &n); ...
随机推荐
- cookie、session和token
https://zhuanlan.zhihu.com/p/25495290?utm_source=wechat_session&utm_medium=social 一.cookie 众所周知, ...
- Python第三弹--------文件和异常
文件读取: pi_digits.txt 3.1415926535 8979323846 2643383279 file_reader.py with open('pi_digits.txt') ...
- 【LeetCode每天一题】Median of Two Sorted Arrays(两数组中的中位数)
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the tw ...
- ida信息获取函数
idc. http://www.cnblogs.com/fply/p/8503929.html 获取ida可执行文件路径 GetIdaDirectory() print GetIdaDirect ...
- 日线做多,15min做空的情况收集
- filename
package com.enjoyor.soa.traffic.server.tms.controller; import java.io.BufferedReader;import java.io. ...
- linux中使用另一用户打开拥有图形界面的程序
在archlinux中使用oracle用户执行oui无法显示图形界面的问题.结果没解决,后来发现执行 xhost +si:localuser:oracle, 然后再使用oracle用户执行oui即可. ...
- springboot的默认访问路径
注意:默认配置的/**映射到/static(或/public ,/resources,/META-INF/resources) 当请求/index.html的时候,Spring MVC 会在/stat ...
- vs2013未找到与约束匹配的导出
解决方法: 1.关闭VS: 2.去C:/Users/<your users name>/AppData/Local/Microsoft/VisualStudio/12.0/Componen ...
- JavaScript--常用的输出方式
1.alert("要输出的内容"); 在浏览器中弹出一个对话框,然后把要输出的内容展示出来 2.document.write("要输出的内容"); ...