编程打造智能家:创新项目与DIY指南

需积分: 10 0 下载量 138 浏览量 更新于2024-07-29 收藏 8.8MB PDF 举报
"《编程你的家》是一本由技术爱好者Mike Riley编写的指南,专为智能手机程序员、web开发者、科技爱好者以及热衷于DIY电子项目的读者设计。该书带领读者探索一系列创新的家庭自动化项目,如通过手机应用远程控制家门、构建能够发送推文的自动喂鸟器以及创建能与你交流的智能家居系统。 书中的内容涵盖了Android智能手机、Arduino硬件平台、X10控制器、各种传感器、伺服马达、编程语言(如Python或C++)、Web框架以及移动软件开发工具包(SDK)的使用。对于读者来说,基本的Arduino硬件知识和对创新思维的兴趣是必要的,同时最好具备一定的应用开发经验。书中项目涉及的硬件设备广泛,包括传感器、执行器、移动设备和无线通信模块,作者会指导读者去哪里获取这些资源。 《编程你的家》不仅提供了实用的技巧和知识,还强调了创新和实用性,让读者能够低成本地实现高端的家庭自动化。例如,书中介绍的Web-Enabled Light Switch项目不仅增加了家庭的便利性和安全性,还展示了RS-232通信的应用。而Tweeting Bird Feeder项目则展示了无线电通信在家庭中的其他用途,对环境保护也有所贡献。 这本书不仅是家庭自动化爱好者的宝典,也为初学者和进阶者提供了一个共同欣赏Arduino潜力的平台。如同软件工程师推崇"The Gang of Four Patterns Book"一样,Sven Davies预测,《编程你的家》将逐渐成为DIY领域的经典参考书籍,激发读者创造更智能、个性化的家居环境,从而提升生活品质并推动科技进步。"

用代码解决这个问题The program committee of the school programming contests, which are often held at the Ural State University, is a big, joyful, and united team. In fact, they are so united that the time spent together at the university is not enough for them, so they often visit each other at their homes. In addition, they are quite athletic and like walking. Once the guardian of the traditions of the sports programming at the Ural State University decided that the members of the program committee spent too much time walking from home to home. They could have spent that time inventing and preparing new problems instead. To prove that, he wanted to calculate the average distance that the members of the program committee walked when they visited each other. The guardian took a map of Yekaterinburg, marked the houses of all the members of the program committee there, and wrote down their coordinates. However, there were so many coordinates that he wasn't able to solve that problem and asked for your help. The city of Yekaterinburg is a rectangle with the sides parallel to the coordinate axes. All the streets stretch from east to west or from north to south through the whole city, from one end to the other. The house of each member of the program committee is located strictly at the intersection of two orthogonal streets. It is known that all the members of the program committee walk only along the streets, because it is more pleasant to walk on sidewalks than on small courtyard paths. Of course, when walking from one house to another, they always choose the shortest way. All the members of the program committee visit each other equally often. Input The first line contains the number n of members of the program committee (2 ≤ n ≤ 105). The i-th of the following n lines contains space-separated coordinates xi, yi of the house of the i-th member of the program committee (1 ≤ xi, yi ≤ 106). All coordinates are integers. Output Output the average distance, rounded down to an integer, that a member of the program committee walks from his house to the house of his colleague.

2023-05-26 上传