#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:点和正方形的关系的更多相关文章

  1. 计算概论(A)/基础编程练习2(8题)/8:1的个数

    #include<stdio.h> int main() { ; // 存储测试数据的二进制形式中1的个数 int bian[N]; // 输入十进制整数N 表示N行测试数据 scanf( ...

  2. 计算概论(A)/基础编程练习2(8题)/7:整数的个数

    #include<stdio.h> int main() { ] = {}; // 输入k个正整数 scanf("%d",&k); // 循环读入和进行算术 w ...

  3. 计算概论(A)/基础编程练习2(8题)/6:数组逆序重放

    #include<stdio.h> int main() { // 输入n个整数 ; scanf("%d", &n); // 循环读入元素 while(scan ...

  4. 计算概论(A)/基础编程练习1(8题)/2:苹果和虫子

    #include<stdio.h> #include<math.h> int main() { /* n个苹果 每x小时能吃掉一个苹果 经过y小时 */ float n, x, ...

  5. 计算概论(A)/基础编程练习1(8题)/1:大象喝水

    #include<stdio.h> int main() { ; // n < 100 scanf("%d", &n); // 循环遍历判断 再进行平方和 ...

  6. 计算概论(A)/基础编程练习2(8题)/4:骑车与走路

    #include<stdio.h> int main() { // 待处理的数据数量n ; scanf("%d", &n); float meters[n]; ...

  7. 计算概论(A)/基础编程练习2(8题)/3:计算三角形面积

    #include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, ...

  8. 计算概论(A)/基础编程练习2(8题)/2:计算书费

    #include<stdio.h> int main() { // 声明与初始化 ; // k组测试数据的总费用 double s[k]; // 单价表 double price[]= { ...

  9. 计算概论(A)/基础编程练习2(8题)/1:求平均年龄

    #include<stdio.h> int main() { // 声明与初始化 , s=, age=; // 输入学生人数 scanf("%d", &n); ...

随机推荐

  1. vue 常用问题

    缺少style-loader 或者 stylus-loader 等问题 在文件[package.json]分支:[devDependencies]添加 版本号: "stylus": ...

  2. Kinect2.0获取数据

    最近事情真是多,今天抽空研究一下Kinec2.0的数据获取! 系统要求 https://developer.microsoft.com/en-us/windows/kinect/hardware-se ...

  3. 【Java】-NO.12.Java.2.OCJP.1.001-【Java OCJP】-

    1.0.0 Summary Tittle:[Java]-NO.12.Java.2.OCJP.1.001-[Java OCJP]- Style:Java Series:OCJP Since:2017-0 ...

  4. 【LeetCode每天一题】Group Anagrams(变位词组)

    Given an array of strings, group anagrams together. Example: Input: ["eat", "tea" ...

  5. [LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal_Medium tag: Tree Traversal

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  6. [LeetCode] 35. Search Insert Position_Easy tag: Binary Search

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  7. [LeetCode] 581. Shortest Unsorted Continuous Subarray_Easy tag: Sort, Stack

    Given an integer array, you need to find one continuous subarray that if you only sort this subarray ...

  8. cocos2d JS 监听键盘触摸响应事件(cc.EventListener.KEYBOARD)

    除了可以监听键盘按键,还可以是终端设备的各个菜单键,都能使用同一个监听器来进行处理. //给statusLabel绑定键盘事件 cc.eventManager.addListener({ event: ...

  9. (已解决)iOS真机运行 Xcode报错(libpng error: CgBI: unhandled critical chunk)

    Cocos2d-x加载图片资源出现libpng error: CgBI: unhandled critical chunk Xcode7.3 设置Remove Text Metadata From P ...

  10. list.remove出错 报 Not source之类的错误

    private static String removePreviousString(String str,String strPre){ String[] strArray = str.split( ...