计算两个矩形的重合面积
import math
x1, y1, x2, y2 = input().split(" ")
x1, y1, x2, y2=int(x1), int(y1), int(x2), int(y2)
# print(x1, y1, x2, y2)
x1,x2 = min(x1,x2),max(x1,x2)
y1,y2= min(y1,y2),max(y1,y2) # print(x1, y1, x2, y2) x3, y3, x4, y4 = input().split(" ")
x3, y3, x4, y4 = int(x3), int(y3), int(x4), int(y4)
x3,x4 = min(x3,x4),max(x3,x4)
y3,y4 = min(y3,y4),max(y3,y4) # print(x3, y3, x4, y4) if (x2<=x3 or x4<=x1) and (y2 <= y3 or y4<=y1):
print(0)
else:
lens = min(x2, x4) - max(x1, x3)
wide = min(y2, y4) - max(y1, y3)
print(lens*wide)

字符串重叠输出

import string

in_str = input()
nums = string.digits a = ""
strs = ""
num = ""
for i in range(len(in_str)):
if in_str[i] not in nums:
a = a+in_str[i]
else:
if i == len(in_str)-1 or (in_str[i+1] not in nums):
num = int(num + in_str[i])
strs = strs + a*num
a=""
num=""
else:
num = num + in_str[i] print(strs)

Python 实现两个矩形重合面积的更多相关文章

  1. Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box)

    Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box) function DecideOberlap(BBox_x1, BBox_y1, BBox_x2, ...

  2. hdu 1255 覆盖的面积(求覆盖至少两次以上的面积)

    了校赛,还有什么途径可以申请加入ACM校队?  覆盖的面积 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  3. Lodop打印设计矩形重合预览线条变粗

    LODOP中的打印设计是辅助进行开发的,实际打印效果应以预览为准,很多效果都是在设计界面显示不出来,或设计和预览界面有差异.例如add_print_text文本的字间距.行间距,旋转,还有允许标点溢出 ...

  4. hdu2056 矩形重叠面积(水题)

    题意:       给你两个矩形,问你他们的重叠面积是多少. 思路:      这两个矩形是平行x和y轴的,所以水题,不解释. #include<stdio.h> typedef stru ...

  5. python保留两位小数

    python保留两位小数: In [1]: a = 5.026 In [2]: b = 5.000 In [3]: round(a,2) Out[3]: 5.03 In [4]: round(b,2) ...

  6. python将两个数组合并成一个数组的两种方法的代码

    内容过程中,把写内容过程中常用的内容收藏起来,下面的资料是关于python将两个数组合并成一个数组的两种方法的内容,希望能对小伙伴们有帮助. c1 = ["Red","G ...

  7. TZOJ 2392 Bounding box(正n边形三点求最小矩形覆盖面积)

    描述 The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located ...

  8. hdu 5120 Intersection 两个圆的面积交

    Intersection Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) P ...

  9. POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

    题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...

随机推荐

  1. 每天一道Rust-LeetCode(2019-06-06)

    每天一道Rust-LeetCode(2019-06-02) Z 字形变换 坚持每天一道题,刷题学习Rust. 原题 题目描述 示例: 输入: 3 输出: 5 解释: 给定 n = 3, 一共有 5 种 ...

  2. Python进阶-XI 常用模块之一:collections、time、random、os、sys

    简要介绍一下各种集合: 列表.元组.字典.集合(含frozenset).字符串.堆栈(如手枪弹夹:先进后出).队列(如马克沁机枪的弹夹:先进先出) 1.collections 1)queue 队列介绍 ...

  3. map的基本操作

    向map添加元素: 因为map是不允许出现重复关键字的,所以如果重复插入键相同的元素后面的元素是不会插入成功的,下面是一个验证程序: #include<iostream> #include ...

  4. vector的基本操作

    vector怎么删除元素? #include<iostream> #include<vector> using namespace std; int main() { vect ...

  5. 洛谷 P3742 umi的函数

    传送门 思路 \(loceaner\)已经蔡虚鲲到连红题都不会做了 因为有\(special\ judge\)所以我们就可以瞎搞了! 由题目可知,只要有一个\(y[i] > x[i]\)则一定没 ...

  6. 在 Vue 中使用 装饰器 Decorator

    Decorator 的语法还没有通过提案,所以项目中很少用.不过最近刚好有一个需求用到了. 装饰器的语法 http://es6.ruanyifeng.com/#docs/decorator 需求是,有 ...

  7. ES6中ArrayBuffer与计算机字节序

    1.什么事字节序? 字节序指的是数值在内存中的表示方式. const buffer = new ArrayBuffer(16); const int32View = new Int32Array(bu ...

  8. python字符串格式化方法%s和format函数

    1.%s方法 一个例子 print("my name is %s and i am %d years old" %("xiaoming",18) 输出结果:my ...

  9. Harmonious Army

    Harmonious Army Now, Bob is playing an interesting game in which he is a general of a harmonious arm ...

  10. python多条插入问题

    多条插入用excutemany(listtuple) #coding=utf-8 import MySQLdb import traceback sqlstr= "insert into t ...