springboot基礎(80):redis geospatial的應用

文章目錄

  • 前言
  • redis geospatial
  • 如何從地圖上獲取經緯度
  • springboot 的相關方法調用
    • 準備redis服務器
    • 引用的依賴
    • 預設位置的key
    • GEOADD 添加位置
    • GEORADIUS 獲取指定經緯度附件的停車場(deprecated)
    • GEORADIUS 獲取指定成員附件的停車場(deprecated)
    • GEOSEARCH 搜索指定經緯度附件的停車場
    • GEOSEARCH 搜索指定成員附件的停車場
    • GEOPOS獲取指定成員經緯度
    • GEODIST獲取兩點之間的距離
    • GEOHASH獲取坐標的hash
    • ZREM 移除位置
  • 數學球面計算兩點距離

前言

基于redis geospatial的應用比較廣泛,比如需要獲取附件5公里的停車場。

官方文檔:https://redis.io/docs/data-types/geospatial/

代碼已分享至Gitee:https://gitee.com/lengcz/redisgeo

redis geospatial

用于地理位置服務的計算,它能做哪些?

  • 我周邊的共享單車的信息,可以按距離輸出
  • 兩坐標、車輛之間的距離

如何從地圖上獲取經緯度

高德地圖:
https://lbs.amap.com/demo/javascript-api/example/map/click-to-get-lnglat/

百度地圖:
https://api.map.baidu.com/lbsapi/getpoint/index.html

springboot 的相關方法調用

準備redis服務器

需要安裝redis 服務器

引用的依賴

		<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency>

注意本demo中的springboot版本為2.7.15,如果你的版本較低,可能部分GEOSEARCH 的API不可用。
如果遇到demo中的示例出現報紅,請考慮是否為依賴版本過低。

預設位置的key

private String positionKey = "parking";

GEOADD 添加位置

官方文檔: https://redis.io/commands/geoadd/

GEOADD key [NX | XX] [CH] longitude latitude member [longitudelatitude member ...]

注意經緯度需要在范圍內

  • 經度 -180到180
  • 緯度 -85.05112878到85.05112878

如果你添加的經緯度超出范圍會報錯

XX: 僅更新已存在的元素。永遠不要添加元素。
NX:不要更新已經存在的元素。始終添加新元素。
CH:將返回值從添加的新元素數量修改為更改的元素總數(CH是changed的縮寫)。已更改的圖元是添加的新元素和已更新坐標的現有圖元。因此,命令行中指定的分數與過去相同的元素將不被計算在內。注意:通常情況下,GEOADD的返回值只計算添加的新元素數量。

 @Testvoid geoAdd(@Autowired RedisTemplate redisTemplate) {System.out.println("--------添加位置-----");GeoOperations geoOperations = redisTemplate.opsForGeo();{Long addedNum = geoOperations.add(positionKey, new Point(-122.27652, 37.805186), "10001:市圖書館");System.out.println(addedNum);}{Long addedNum = geoOperations.add(positionKey, new Point(-122.2674626, 37.8062344), "10002:百貨大樓");System.out.println(addedNum);}{Long addedNum = geoOperations.add(positionKey, new Point(-122.2469854, 37.8104049), "10003:科學中心");System.out.println(addedNum);}{Long addedNum = geoOperations.add(positionKey, new Point(-122.2625112, 37.793513), "10004:博物館");System.out.println(addedNum);}System.out.println("--------添加位置END-----");}

GEORADIUS 獲取指定經緯度附件的停車場(deprecated)

官方文檔: https://redis.io/commands/georadius/

從Redis版本6.2.0開始,此命令被視為已棄用。
在遷移或編寫新代碼時,可以用帶有BYRADIUS參數的GEOSEARCH和GEOSEARCHSTORE替換它。

GEORADIUS key longitude latitude radius <M | KM | FT | MI>[WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC][STORE key | STOREDIST key]

單位

  • m 米
  • km 千米
  • mi 英里
  • ft 英尺
  @Testvoid geoRadius(@Autowired RedisTemplate redisTemplate) {// 指定經緯度附近5公里的停車場Circle circle = new Circle(new Point(-122.2612767, 37.793684), RedisGeoCommands.DistanceUnit.KILOMETERS.getMultiplier());RedisGeoCommands.GeoRadiusCommandArgs args = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates().includeDistance().sortAscending().limit(5);GeoResults<RedisGeoCommands.GeoLocation<String>> results = redisTemplate.opsForGeo().radius(positionKey, circle, args);System.out.println(results);for (GeoResult<RedisGeoCommands.GeoLocation<String>> g : results) {System.out.println(g);String addr = g.getContent().getName();System.out.println("addr:" + addr + ",distance:" + g.getDistance().getValue());}}

運行結果

GeoResult [content: RedisGeoCommands.GeoLocation(name=10004:博物館, point=Point [x=-122.262509, y=37.793512]), distance: 109.9417 METERS, ]
addr:10004:博物館,distance:109.9417
GeoResult [content: RedisGeoCommands.GeoLocation(name=10002:百貨大樓, point=Point [x=-122.267460, y=37.806234]), distance: 1497.9608 METERS, ]
addr:10002:百貨大樓,distance:1497.9608
GeoResult [content: RedisGeoCommands.GeoLocation(name=10001:市圖書館, point=Point [x=-122.276520, y=37.805185]), distance: 1852.3499 METERS, ]
addr:10001:市圖書館,distance:1852.3499
GeoResult [content: RedisGeoCommands.GeoLocation(name=10003:科學中心, point=Point [x=-122.246984, y=37.810404]), distance: 2244.1523 METERS, ]
addr:10003:科學中心,distance:2244.1523

GEORADIUS 獲取指定成員附件的停車場(deprecated)

 @Testvoid geoRadius2(@Autowired RedisTemplate redisTemplate) {// 指定地址附近5公里的停車場RedisGeoCommands.GeoRadiusCommandArgs args = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates().includeDistance().sortAscending().limit(5);GeoResults<RedisGeoCommands.GeoLocation<String>> results = redisTemplate.opsForGeo().radius(positionKey, "10001:市圖書館", new Distance(5, Metrics.KILOMETERS), args);System.out.println(results);for (GeoResult<RedisGeoCommands.GeoLocation<String>> g : results) {System.out.println(g);String addr = g.getContent().getName();System.out.println("addr:" + addr + ",distance:" + g.getDistance().getValue());}}

執行結果

GeoResult [content: RedisGeoCommands.GeoLocation(name=10001:市圖書館, point=Point [x=-122.276520, y=37.805185]), distance: 0.0 KILOMETERS, ]
addr:10001:市圖書館,distance:0.0
GeoResult [content: RedisGeoCommands.GeoLocation(name=10002:百貨大樓, point=Point [x=-122.267460, y=37.806234]), distance: 0.8047 KILOMETERS, ]
addr:10002:百貨大樓,distance:0.8047
GeoResult [content: RedisGeoCommands.GeoLocation(name=10004:博物館, point=Point [x=-122.262509, y=37.793512]), distance: 1.7894 KILOMETERS, ]
addr:10004:博物館,distance:1.7894
GeoResult [content: RedisGeoCommands.GeoLocation(name=10003:科學中心, point=Point [x=-122.246984, y=37.810404]), distance: 2.6597 KILOMETERS, ]
addr:10003:科學中心,distance:2.6597

GEOSEARCH 搜索指定經緯度附件的停車場

官方文檔: https://redis.io/commands/geosearch/

注意該命令從redis 6.0.2開始。

GEOSEARCH key <FROMMEMBER member | FROMLONLAT longitude latitude><BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM |FT | MI>> [ASC | DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST][WITHHASH]
    @Testvoid geoSearch(@Autowired RedisTemplate redisTemplate) {// 指定經緯度附近5公里的停車場RedisGeoCommands.GeoSearchCommandArgs geoSearchCommandArgs = RedisGeoCommands.GeoSearchCommandArgs.newGeoSearchArgs().includeCoordinates().includeDistance().sortAscending();GeoResults<RedisGeoCommands.GeoLocation> searchResult = redisTemplate.opsForGeo().search(positionKey, new GeoReference.GeoCoordinateReference(-122.2612767, 37.793684), new Distance(5, Metrics.KILOMETERS), geoSearchCommandArgs);
//        System.out.println(searchResult);List<GeoResult<RedisGeoCommands.GeoLocation>> content = searchResult.getContent();for (GeoResult<RedisGeoCommands.GeoLocation> g : content) {
//            System.out.println(g);RedisGeoCommands.GeoLocation content1 = g.getContent();Distance distance = g.getDistance();System.out.println("content1:" + content1 + ",distance:" + distance);}}

執行結果

content1:RedisGeoCommands.GeoLocation(name=10004:博物館, point=Point [x=-122.262509, y=37.793512]),distance:0.1099 KILOMETERS
content1:RedisGeoCommands.GeoLocation(name=10001:市圖書館, point=Point [x=-122.276520, y=37.805185]),distance:1.8523 KILOMETERS
content1:RedisGeoCommands.GeoLocation(name=10003:科學中心, point=Point [x=-122.246984, y=37.810404]),distance:2.2442 KILOMETERS

GEOSEARCH 搜索指定成員附件的停車場

 @Testvoid geoSearch2(@Autowired RedisTemplate redisTemplate) {// 指定成員附近5公里的停車場RedisGeoCommands.GeoSearchCommandArgs geoSearchCommandArgs = RedisGeoCommands.GeoSearchCommandArgs.newGeoSearchArgs().includeCoordinates().includeDistance().sortAscending();GeoResults<RedisGeoCommands.GeoLocation> searchResult = redisTemplate.opsForGeo().search(positionKey, new GeoReference.GeoMemberReference<>("10004:博物館"), new Distance(5, Metrics.KILOMETERS), geoSearchCommandArgs);
//        System.out.println(searchResult);List<GeoResult<RedisGeoCommands.GeoLocation>> content = searchResult.getContent();for (GeoResult<RedisGeoCommands.GeoLocation> g : content) {
//            System.out.println(g);RedisGeoCommands.GeoLocation content1 = g.getContent();Distance distance = g.getDistance();System.out.println("content1:" + content1 + ",distance:" + distance);}}

執行結果

content1:RedisGeoCommands.GeoLocation(name=10004:博物館, point=Point [x=-122.262509, y=37.793512]),distance:0.0 KILOMETERS
content1:RedisGeoCommands.GeoLocation(name=10001:市圖書館, point=Point [x=-122.276520, y=37.805185]),distance:1.7894 KILOMETERS
content1:RedisGeoCommands.GeoLocation(name=10003:科學中心, point=Point [x=-122.246984, y=37.810404]),distance:2.3219 KILOMETERS

GEOPOS獲取指定成員經緯度

官方文檔 https://redis.io/commands/geopos/

GEOPOS key [member [member ...]]
    @Testvoid geoGetPoints(@Autowired RedisTemplate redisTemplate) {List<Point> points = redisTemplate.opsForGeo().position(positionKey, "10003:科學中心", "10004:博物館");System.out.println(points);}

執行結果

[Point [x=-122.246984, y=37.810404], Point [x=-122.262509, y=37.793512]]

GEODIST獲取兩點之間的距離

官方文檔: https://redis.io/commands/geodist/

命令

GEODIST key member1 member2 [M | KM | FT | MI]

單位

  • m 米
  • km 千米
  • mi 英里
  • ft 英尺
    @Testpublic void testDist(@Autowired RedisTemplate redisTemplate) {Distance distance = redisTemplate.opsForGeo().distance(positionKey, "10003:科學中心", "10004:博物館", RedisGeoCommands.DistanceUnit.KILOMETERS);System.out.println(distance);}

執行結果

2.3219 KILOMETERS

GEOHASH獲取坐標的hash

官方文檔: https://redis.io/commands/geohash/

GEOHASH key [member [member ...]]

這里給定的10005不存在

    @Testpublic void testGeoHash(@Autowired RedisTemplate redisTemplate) {List<String> results = redisTemplate.opsForGeo().hash(positionKey, "10004:博物館", "10002:百貨大樓", "10005:歡樂海岸");System.out.println(results);}

執行結果

[9q9p1b55jj0, 9q9p1drt380, null]

ZREM 移除位置

官方沒有GEODEL,需要使用ZREM命令

官方文檔: https://redis.io/commands/zrem/

 @Testpublic void testGeoRemove(@Autowired RedisTemplate redisTemplate) {Long remove = redisTemplate.opsForGeo().remove(positionKey, "10002:百貨大樓");List<String> results = redisTemplate.opsForGeo().hash(positionKey, "10004:博物館", "10002:百貨大樓", "10005:歡樂海岸");System.out.println(results);}

執行結果,可以看到10002百貨大樓已經被移除了。

[9q9p1b55jj0, null, null]

注意: redis geo沒有GEODEL命令,需要使用ZREM命令刪除元素

數學球面計算兩點距離

/*** 通過球面計算距離*/
public class DistanceUtil {/*** 赤道半徑(m)*/public final static double RC = 6378137;/*** 極半徑(m)*/public final static double RJ = 6356725;/*** 將角度轉化為弧度*/public static double radians(double d) {return d * Math.PI / 180.0;}/*** 根據兩點經緯度((longitude and latitude))坐標計算直線距離* <p>* S = 2arcsin√sin2(a/2)+cos(lat1)*cos(lat2)*sin2(b/2) ̄*6378137* <p>* 1. lng1 lat1 表示A點經緯度,lng2 lat2 表示B點經緯度;<br>* 2. a=lat1 – lat2 為兩點緯度之差 b=lng1 -lng2 為兩點經度之差;<br>* 3. 6378137為地球赤道半徑,單位為米;** @param longitude1 點1經度* @param latitude1  點1緯度* @param longitude2 點2經度* @param latitude2  點2緯度* @return 距離,單位米(M)* @see <a href=* "https://zh.wikipedia.org/wiki/%E5%8D%8A%E6%AD%A3%E7%9F%A2%E5%85%AC%E5%BC%8F">* 半正矢(Haversine)公式</a>*/public static double getDistanceFromToLngLat(double longitude1, double latitude1, double longitude2, double latitude2) {// 將角度轉化為弧度double radLongitude1 = radians(longitude1);double radLatitude1 = radians(latitude1);double radLongitude2 = radians(longitude2);double radLatitude2 = radians(latitude2);double a = radLatitude1 - radLatitude2;double b = radLongitude1 - radLongitude2;return 2 * Math.asin(Math.sqrt(Math.sin(a / 2) * Math.sin(a / 2)+ Math.cos(radLatitude1) * Math.cos(radLatitude2) * Math.sin(b / 2) * Math.sin(b / 2))) * (RC);}/*** 獲取指定角度方向上的經緯度(longitude and latitude)<br>* 以原始點的經緯度為基點,構建XY二維坐標線,則angle角度則從x軸起算。<br>* 說明:LBS查找,東西南北四個方向的最遠點,構建矩形,在矩形框方位內, 才有可能是該距離方位內的坐標,然后利用距離公式從小范圍內找坐標** @param origLongitude    基點經度* @param origLatitude     基點緯度* @param distance         距離(m)* @param angle            角度(0~360)* @param 經緯度(該角度指定距離的經緯度)*/public static Coordinate getCoordinate(double origLongitude, double origLatitude, double distance, double angle) {double x = distance * Math.sin(angle * Math.PI / 180.0);double y = distance * Math.cos(angle * Math.PI / 180.0);double r = RJ + (RC - RJ) * (90.0 - origLongitude) / 90.0;//由于地球不是標準的球體,中間粗,兩頭細,這里計算平均半徑rdouble d = r * Math.cos(origLongitude * Math.PI / 180);double newLongitude = (y / r + origLongitude * Math.PI / 180.0) * 180.0 / Math.PI;double newLatitude = (x / d + origLatitude * Math.PI / 180.0) * 180.0 / Math.PI;return new Coordinate(newLongitude, newLatitude);}
}

測試用例,用例的經緯度為GEOSEARCH示例中目標到科學中心的距離

  @Testvoid getDist() {double longitude1 = -122.2612767;double latitude1 = 37.793684;double longitude2 = -122.2469854;double latitude2 = 37.8104049;double distance = DistanceUtil.getDistanceFromToLngLat(longitude1, latitude1, longitude2, latitude2);System.out.println("經緯度(" + longitude1 + "," + latitude1 + ")到(" + longitude2 + "," + latitude2 + ")的距離為: " + distance + " 米");}

運行測試用例,返回結果與GEO返回的結果基本吻合。

經緯度(-122.2612767,37.793684)(-122.2469854,37.8104049)的距離為: 2246.057783614703

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/211934.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/211934.shtml
英文地址,請注明出處:http://en.pswp.cn/news/211934.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

文心一言API(高級版)使用

文心一言API高級版使用 一、百度文心一言API(高級版)二、使用步驟1、接口2、請求參數3、請求參數示例4、接口 返回示例 三、 如何獲取appKey和uid1、申請appKey:2、獲取appKey和uid 四、重要說明 一、百度文心一言API(高級版) 基于百度文心一言語言大模型的智能文本對話AI機器…

歸并排序--分治法

代碼 #include<iostream> using namespace std;void merge(int arr[], int p, int q, int r, int temp[]) {int i p;int j q 1;int k 0;while (i < q && j < r){if (arr[i] < arr[j]){temp[k] arr[i];}else{temp[k] arr[j];}}while (i < q){t…

智能優化算法應用:基于蟻獅算法3D無線傳感器網絡(WSN)覆蓋優化 - 附代碼

智能優化算法應用&#xff1a;基于蟻獅算法3D無線傳感器網絡(WSN)覆蓋優化 - 附代碼 文章目錄 智能優化算法應用&#xff1a;基于蟻獅算法3D無線傳感器網絡(WSN)覆蓋優化 - 附代碼1.無線傳感網絡節點模型2.覆蓋數學模型及分析3.蟻獅算法4.實驗參數設定5.算法結果6.參考文獻7.MA…

ptmalloc:從內存虛擬化說起

前言 本文并不局限于ptmalloc的原理&#xff0c;而是從linux的內存虛擬化和系統調用原理出發&#xff0c;結合各種語言實現&#xff0c;講明內存分配方面的trade off&#xff0c;力圖事無巨細&#xff0c;追根究底。本文內容包括但不限于&#xff1a;NIO原理、0拷貝原理、內存…

Redis 數據的持久化 RDB、AOF、RDB + AOF、No persistence 各自優缺點

文章目錄 一、RDB (Redis Database)1.1 RDB 優勢1.2 RDB 缺點1.3 RDB 如何工作1.4 RDB配置1.5 開啟/關閉&#xff0c;RDB快照策略&#xff0c;save指令1.6 持久化硬盤文件&#xff0c;dbfilename指令1.7 持久化硬盤文件的存儲地址&#xff0c;dir指令 二、AOF (Append Only Fil…

leetcode:643. 子數組最大平均數 I(滑動窗口)

一、題目 鏈接&#xff1a;643. 子數組最大平均數 I - 力扣&#xff08;LeetCode&#xff09; 函數原型&#xff1a; double findMaxAverage(int* nums, int numsSize, int k) 二、思路 滑動窗口&#xff1a; 先計算數組前k個元素總和&#xff0c;作為第一個窗口&#xff0c;默…

vlog如何降低重復率

大家好&#xff0c;今天來聊聊vlog如何降低重復率&#xff0c;希望能給大家提供一點參考。 以下是針對論文重復率高的情況&#xff0c;提供一些修改建議和技巧&#xff1a; vlog如何降低重復率 Vlog作為一種流行的視頻日志形式&#xff0c;常常被人們用于記錄日常生活、分享經…

pta模擬題——7-34 刮刮彩票

“刮刮彩票”是一款網絡游戲里面的一個小游戲。如圖所示&#xff1a; 每次游戲玩家會拿到一張彩票&#xff0c;上面會有 9 個數字&#xff0c;分別為數字 1 到數字 9&#xff0c;數字各不重復&#xff0c;并以 33 的“九宮格”形式排布在彩票上。 在游戲開始時能看見一個位置上…

Lambda表達式規則,用法

Lambda表達式是JDK8新增的一種語法格式 1.作用 簡化匿名內部類的代碼寫法 Lambad用法前提&#xff1a;只能簡化函數式接口&#xff08;一般加有Funcationallnterface&#xff09;&#xff08;有且僅有一個抽象方法&#xff09;的匿名內部類 匿名內部類&#xff1a;(本質是對…

url轉pdf或者html轉pdf工具 — iText實現url轉pdf

url轉pdf或者html轉pdf工具 — iText實現url轉pdf 參考資料&#xff1a; https://kb.itextpdf.com/itext/can-i-generate-a-pdf-from-a-url-instead-of-from-a- http://www.micmiu.com/opensource/expdoc/itext-pdf-demo/ https://blog.51cto.com/u_16237557/7263784 iText&…

sensitive-word 敏感詞/臟詞開源工具-v.0.10.0-臟詞分類標簽支持

sensitive-word sensitive-word 基于 DFA 算法實現的高性能敏感詞工具。 創作目的 實現一款好用敏感詞工具。 基于 DFA 算法實現&#xff0c;目前敏感詞庫內容收錄 6W&#xff08;源文件 18W&#xff0c;經過一次刪減&#xff09;。 后期將進行持續優化和補充敏感詞庫&…

幾種常用的壓力測試工具

1. JMeter 官網: Apache JMeter簡介: Apache JMeter 是一個開源軟件&#xff0c;主要用于性能測試和壓力測試。它可以用來測試靜態和動態資源&#xff0c;如文件、Web服務、REST API等。下載與使用: 訪問官網下載安裝包。解壓安裝包并運行 JMeter。通過創建測試計劃來設置壓力…

2023年終總結-輕舟已過萬重山

自我介紹 高考大省的讀書人 白&#xff0c;隴西布衣&#xff0c;流落楚、漢。-與韓荊州書 我來自孔孟故里山東濟寧&#xff0c;也許是小學時的某一天&#xff0c;我第一次接觸到了電腦&#xff0c;從此對它產生了強烈的興趣&#xff0c;高中我有一個愿望&#xff1a;成為一名計…

設計模式再探——裝飾模式

目錄 一、背景介紹二、思路&方案三、過程1.裝飾模式簡介2.裝飾模式的類圖3.裝飾模式代碼4.裝飾模式&#xff0c;職責父類拆分的奧義5.裝飾模式&#xff0c;部件抽象類的無中生有 四、總結五、升華 一、背景介紹 最近公司在做架構模型的時候&#xff0c;涉及到裝飾模式的研…

html網頁設計 01marquee標簽廣告滾動(1)

<!DOCTYPE html> <html><head><meta charset"utf-8"><title></title></head><body><!-- scrollamount:數字越大&#xff0c;滾動越快direction:滾動方向滾動的類型behaior"slide",文字滾動到邊界后就會…

Python中的lambda匿名函數詳解以及三種經典使用場景

lambda匿名函數 匿名函數&#xff0c;顧名思義就是不需要具體定義函數名的函數。我們首先拋開復雜的定義&#xff0c;看兩個具體例子。 先看一個無參數函數的例子。假設我們需要一個return 1的函數&#xff0c;如果使用普通的函數定義方式&#xff0c;其代碼為&#xff1a; …

vuepress-----20、全文搜索

默認主題自帶的搜索, 只會為頁面的標題、h2、h3 以及 tags構建搜索索引。所以盡量將圍繞知識點的關鍵字體現到標題上。而 tags 更為靈活&#xff0c;可以把相關的能想到的關鍵字都配置到 tags 中&#xff0c;以方便搜索。 默認插件介紹 (opens new window) 默認主體配置 (ope…

電子秤ADC芯片CS1237技術資料問題合集

問題11&#xff1a;實際應用中&#xff0c;多個稱重傳感器應該怎么與ADC連接&#xff1f; 解答&#xff1a;如果傳感器是測量同一物體&#xff08;例如&#xff1a;廚房垃圾處理器&#xff09;&#xff0c;一般建議使用并聯的方式。則相同類型的信號線連接在一起。對于傳感器的…

C語言指針基礎題(一)

目錄 例題一題目解析答案 例題二題目解析答案 例題三題目解析答案 例題四題目解析答案 例題五題目解析答案 例題六題目解析答案 例題七題目解析答案 感謝各位大佬對我的支持,如果我的文章對你有用,歡迎點擊以下鏈接 &#x1f412;&#x1f412;&#x1f412; 個人主頁 &#x…

C++ 教程 - 01 基礎篇

文章目錄 C介紹環境配置第一個cpp程序案例練習 變量常量關系運算符邏輯運算符條件運算符位運算符類型轉換分支循環程序調用綜合案例 C介紹 基于C語言&#xff0c;繼承了C的所有語法&#xff1b; 靜態類型語言&#xff0c;需要先編譯&#xff0c;再執行&#xff1b; 貼近底層硬…