
C++
GIS-Developer
这个作者很懒,什么都没留下…
展开
-
异或运算
#include <bits/stdc++.h>int operator_xor(int a, int b, int c) { std::vector<int> flags; flags.push_back(a); flags.push_back(b); flags.push_back(c); int acc = std::accumulate (flags.begin(), flags.end(), 0, std::bit_xor<int>());...原创 2020-11-14 07:59:48 · 471 阅读 · 0 评论 -
C++ 基本运算
距离第一次认识C++,已经过去了14年有余。重温之。#include <stdio.h>void basicNumberTypes(){ int n1 = 1378; short n2; char c = 'a'; double d1 = 7.809; double d2; n2 = c; // n2 = 'a' printf("c = %c, n2 = %d\n", c, n2); // c = a, n2 = 97.原创 2020-05-21 20:04:11 · 524 阅读 · 0 评论 -
C++ 数组操作
一维数组长度: end(arr) - begin(arr)double arr[12] = {100.00,489.12,12454.12,1234.10,823.05,109.20,5.27,1542.25,839.18,83.99,1295.01,1.75};int arrLength = end(arr) - begin(arr);#TODO:数组排序数组反转数组维度原创 2020-05-20 21:18:45 · 446 阅读 · 0 评论 -
C++ 基本数据类型 int, double
证明:int占4个字节,double占8个字节。#include <stdio.h>#include <iostream>using namespace std;int main(){ int i[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; double d[10] = {1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2}; printf("size of i[0]原创 2020-05-15 22:00:29 · 1579 阅读 · 0 评论 -
C++ float转string 不含小数末尾多余的0
使用 ostringstream#include <iostream>#include <iomanip>using namespace std;int main(){ float s = 6.7592; cout << to_string(s) << endl; // 6.759200 double k = 6.7592; cout << to_string(k) << endl;原创 2020-05-20 11:48:56 · 3186 阅读 · 0 评论