中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

免費h5網(wǎng)站模版谷歌seo服務(wù)

免費h5網(wǎng)站模版,谷歌seo服務(wù),用vs做網(wǎng)頁是怎么創(chuàng)建網(wǎng)站的,WordPress修改模板相對路徑P8720 [藍橋杯 2020 省 B2] 平面切分--set、pair 題目 分析一、pair1.1pair與vector的區(qū)別1.2 兩者使用場景兩者組合使用 二、set2.1核心特點2.2set的基本操作2.3 set vs unordered_set示例:統(tǒng)計唯一單詞數(shù)代碼 題目 分析 大佬寫的很明白,看這兒 我講講…

P8720 [藍橋杯 2020 省 B2] 平面切分--set、pair

      • 題目
  • 分析
    • 一、pair
    • 1.1pair與vector的區(qū)別
    • 1.2 兩者使用場景
    • 兩者組合使用
  • 二、set
    • 2.1核心特點
    • 2.2set的基本操作
    • 2.3 set vs unordered_set
    • 示例:統(tǒng)計唯一單詞數(shù)
      • 代碼

題目

在這里插入圖片描述

分析

大佬寫的很明白,看這兒

我講講其中用到的知識點吧!

一、pair

pair是 C++ 中的一個模板類,用于存儲兩個值(可以是不同類型)。

1、基本用法

#include <iostream>
#include <utility> // pair 的頭文件
using namespace std;int main() {pair<int, string> student = {18, "小明"}; // 存儲年齡和姓名cout << "年齡: " << student.first << endl;   // 輸出 18cout << "姓名: " << student.second << endl;  // 輸出 小明return 0;
}

2、核心特性:
pair 中的兩個值可以是不同類型(如 int 和 string)。
通過 .first 和 .second 訪問兩個值。

3、pair 的常見用途

1)存儲關(guān)聯(lián)數(shù)據(jù)
例如,存儲一個點的坐標(biāo) (x, y)

pair<double, double> point = {3.14, 2.71};

2)函數(shù)返回兩個值

pair<bool, int> checkValue(int x) {if (x > 0) return {true, x};else return {false, 0};
}

1.1pair與vector的區(qū)別

在這里插入圖片描述

1.2 兩者使用場景

對pair:

  1. 坐標(biāo) (x, y)。
  2. 一個學(xué)生的年齡和姓名 (int, string)

對vector:

需要存儲一組同類型數(shù)據(jù),例如:
學(xué)生成績列表 [90, 85, 95]。
一組字符串 [“apple”, “banana”, “cherry”]。

兩者組合使用

vector<pair<double, double>> points;
points.push_back({1.0, 2.0}); // 添加點 (1.0, 2.0)
points.push_back({3.0, 4.0}); // 添加點 (3.0, 4.0)// 遍歷所有點
for (auto p : points) {cout << "x: " << p.first << ", y: " << p.second << endl;
}

二、set

set是 C++ 中的一個重要容器,用于存儲一組唯一且有序的元素。set 是 C++ 中的一個重要容器,用于存儲一組唯一且有序的元素。它的核心特性是自動去重自動排序,非常適合處理需要唯一性和順序性的數(shù)據(jù)。

2.1核心特點

在這里插入圖片描述

2.2set的基本操作

(1) 創(chuàng)建 set

#include <set>
using namespace std;set<int> s1;                // 默認升序排列的整數(shù)集合
set<string> s2;             // 字符串集合
set<pair<int, int>> s3;     // 存儲 pair 的集合

(2) 插入元素

s1.insert(3);       // 插入元素 3
s1.insert(1);       // 插入元素 1
s1.insert(2);       // 插入元素 2
s1.insert(3);       // 重復(fù)插入 3,會被自動忽略
// 此時 s1 = {1, 2, 3}

(3) 遍歷 set

//若set<pair<int,int>> s1;
//for(auto &i:s1) cout<<num;
for (auto num : s1) {cout << num << " ";   // 輸出 1 2 3
}

(4) 查找元素

auto it = s1.find(2);
if (it != s1.end()) {cout << "元素 2 存在!" << endl;
}

(5) 刪除元素

s1.erase(2);        // 刪除元素 2
s1.erase(s1.begin()); // 刪除第一個元素(即 1)

2.3 set vs unordered_set

在這里插入圖片描述

示例:統(tǒng)計唯一單詞數(shù)

#include <iostream>
#include <set>
using namespace std;int main() {set<string> uniqueWords;string word;while (cin >> word) {  // 輸入單詞,按 Ctrl+Z (Windows) 或 Ctrl+D (Mac) 結(jié)束uniqueWords.insert(word);}cout << "唯一單詞數(shù): " << uniqueWords.size() << endl;return 0;
}
//輸入:apple banana apple cherry banana
//輸出:唯一單詞數(shù): 3

代碼

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <climits>  // 包含INT_MAX常量
#include <cctype>
using namespace std;
int n;
typedef pair<long double, long double> DL;
set<DL> f;
DL a[1010];int main() {cin >> n;for (int i = 0; i < n; i++) {int k, b;cin >> k >> b;f.insert({k, b});}int cnt = 0;for (auto &i : f) {a[cnt++] = i;}int ans = 1;for (int i = 0; i < cnt; i++) {set<DL> d;for (int j = 0; j < i; j++) {long double k1 = a[i].first;long double b1 = a[i].second;long double k2 = a[j].first;long double b2 = a[j].second;if (k1 == k2)continue;//注意,交點的x,y值是浮點型,別定義成int了!!!long double x = (b2 - b1) / (k1 - k2);long double y = k1 * x + b1;d.insert({x, y});}ans += d.size() + 1;}cout << ans << endl;return 0;
}
http://www.risenshineclean.com/news/36281.html

相關(guān)文章:

  • 瑞安做網(wǎng)站百度云盤官網(wǎng)登錄入口
  • 成都建設(shè)工程交易中心網(wǎng)站深圳seo招聘
  • 扁平化企業(yè)網(wǎng)站媒體發(fā)布平臺
  • 廈門網(wǎng)站制作費用怎么搭建屬于自己的網(wǎng)站
  • 服裝購物網(wǎng)站建設(shè)網(wǎng)絡(luò)營銷組織的概念
  • 如何制作一個官網(wǎng)sem優(yōu)化軟件選哪家
  • 開一個網(wǎng)站建設(shè)公司外鏈工具xg
  • 怎么給公司做微網(wǎng)站軟文關(guān)鍵詞排名推廣
  • 石家莊新聞網(wǎng)seo推廣服務(wù)哪家好
  • 站長工具seo綜合查詢排名怎么做關(guān)鍵詞排名靠前
  • 香港vps可看netflix東營seo網(wǎng)站推廣
  • 做電子商務(wù)系統(tǒng)網(wǎng)站建設(shè)怎么推廣產(chǎn)品最有效
  • 如何在百度上做網(wǎng)站品牌策劃書
  • 福州交通建設(shè)集團官方網(wǎng)站軟文營銷寫作技巧
  • 建設(shè)工程施工合同條例湖北搜索引擎優(yōu)化
  • 織夢映像網(wǎng)絡(luò)推廣seo怎么弄
  • 企業(yè) 網(wǎng)站 程序愛站網(wǎng)關(guān)鍵詞查詢
  • 如何用vps做網(wǎng)站中央新聞
  • 網(wǎng)站如何制作浙江技能培訓(xùn)班
  • 做電商的批發(fā)網(wǎng)站可以直接進入的輿情網(wǎng)站
  • 扶貧基金會網(wǎng)站建設(shè)是哪家公司班級優(yōu)化大師官方網(wǎng)站
  • 中國設(shè)計聯(lián)盟官網(wǎng)短視頻入口seo
  • 網(wǎng)站網(wǎng)頁設(shè)計內(nèi)容百度網(wǎng)盤客服在線咨詢
  • 做網(wǎng)站橫幅用什么軟件好河南網(wǎng)站關(guān)鍵詞優(yōu)化
  • 深圳網(wǎng)站營銷公司談?wù)勀銓ヂ?lián)網(wǎng)營銷的認識
  • 如何幫助網(wǎng)站吸引流量會計培訓(xùn)班一般多少錢
  • 有口碑的app制作武漢seo人才
  • 英文b2c網(wǎng)站建設(shè)今日熱點新聞頭條國內(nèi)
  • 網(wǎng)站網(wǎng)站開發(fā)的山東建站管理系統(tǒng)
  • 搜網(wǎng)站首頁不見了seoseo上海優(yōu)化