高手戏玩c++

C/C++库函数(tolower/toupper)实现字母的大小写转换 C/C++库函数(tolower/toupper)实现字母的大小写转换 本文将介绍库函数实现字母的大小写转换,常用到的是在ctype.h(C++中是cctype)库文件下定义的函数方法。首先来看一下C下tolower/toupper函数实现原型: int tolower(int c) { if ((c >= 'A') && (c <= 'Z')) return c + 阅读详情
toupper,tolower
地球人都知道 C++ 的 string 没有 toupper ,好在这不是个大问题,因为我们有 STL 算法:

string s("heLLo");transform(s.begin(), s.end(), s.begin(), ::toupper);cout transform(s.begin(), s.end(), s.begin(), ::tolower);cout

当然,我知道很多人希望的是 s.to_upper() ,但是对于一个这么通用的 basic_string 来说,的确没办法把这些专有的方法放进来。如果你用 boost stringalgo ,那当然不在话下,你也就不需要读这篇文章了。

------------------------------------------------------------------------
trim
我们还知道 string 没有 trim ,不过自力更生也不困难,比 toupper 来的还要简单:

    string s("   hello   ");    s.erase(0, s.find_first_not_of(" /n"));    cout     s.erase(s.find_last_not_of(' ') + 1);    cout

注意由于 find_first_not_of 和 find_last_not_of 都可以接受字符串,这个时候它们寻找该字符串中所有字符的 absence ,所以你可以一次 trim 掉多种字符。

-----------------------------------------------------------------------
erase
string 本身的 erase 还是不错的,但是只能 erase 连续字符,如果要拿掉一个字符串里面所有的某个字符呢?用 STL 的 erase + remove_if 就可以了,注意光 remove_if 是不行的。    string s("   hello, world. say bye   ");    s.erase(remove_if(s.begin(),s.end(),         bind2nd(equal_to(), ' ')),     s.end());

上面的这段会拿掉所有的空格,于是得到 hello,world.saybye。

-----------------------------------------------------------------------
replace
string 本身提供了 replace ,不过并不是面向字符串的,譬如我们最常用的把一个 substr 换成另一个 substr 的操作,就要做一点小组合:

    string s("hello, world");    string sub("ello, ");    s.replace(s.find(sub), sub.size(), "appy ");    cout

输出为 happy world。注意原来的那个 substr 和替换的 substr 并不一定要一样长。

-----------------------------------------------------------------------
startwith, endwith
这两个可真常用,不过如果你仔细看看 string 的接口,就会发现其实没必要专门提供这两个方法,已经有的接口可以干得很好:

    string s("hello, world");    string head("hello");    string tail("ld");    bool startwith = s.compare(0, head.size(), head) == 0;    cout     bool endwith = s.compare(s.size() - tail.size(), tail.size(), tail) == 0;    cout

当然了,没有 s.startwith("hello") 这样方便。

------------------------------------------------------------------------
toint, todouble, tobool...
这也是老生常谈了,无论是 C 的方法还是 C++ 的方法都可以,各有特色:

    string s("123");    int i = atoi(s.c_str());    cout         int ii;    stringstream(s) >> ii;    cout         string sd("12.3");    double d = atof(sd.c_str());    cout         double dd;    stringstream(sd) >> dd;    cout         string sb("true");    bool b;    stringstream(sb) >> boolalpha >> b;    cout

C 的方法很简洁,而且赋值与转换在一句里面完成,而 C++ 的方法很通用。

------------------------------------------------------------------------
split
这可是件麻烦事,我们最希望的是这样一个接口: s.split(vect, ',') 。用 STL 算法来做有一定难度,我们可以从简单的开始,如果分隔符是空格、tab 和回车之类,那么这样就够了:

    string s("hello world, bye.");    vector vect;
    vect.assign(
        istream_iterator(stringstream(s)),
        istream_iterator()
    );

不过要注意,如果 s 很大,那么会有效率上的隐忧,因为 stringstream 会 copy 一份 string 给自己用。------------------------------------------------------------------------concat把一个装有 string 的容器里面所有的 string 连接起来,怎么做?希望你不要说是 hand code 循环,这样做不是更好?

    vector vect;    vect.push_back("hello");    vect.push_back(", ");    vect.push_back("world");        cout
不过在效率上比较有优化余地。-------------------------------------------------------------------------

reverse
其实我比较怀疑有什么人需要真的去 reverse 一个 string ,不过做这件事情的确是很容易:

  std::reverse(s.begin(), s.end());

上面是原地反转的方法,如果需要反转到别的 string 里面,一样简单:

  s1.assign(s.rbegin(), s.rend());

效率也相当理想。

-------------------------------------------------------------------------

解析文件扩展名
字数多点的写法:

    std::string filename("hello.exe");    std::string::size_type pos = filename.rfind('.');    std::string ext = filename.substr(pos == std::string::npos ? filename.length() : pos + 1);
不过两行,合并成一行呢?也不是不可以:

    std::string ext = filename.substr(filename.rfind('.') == std::string::npos ? filename.length() : filename.rfind('.') + 1);

我知道,rfind 执行了两次。不过第一,你可以希望编译器把它优化掉,其次,扩展名一般都很短,即便多执行一次,区别应该是相当微小。

******************
distance
很多时候我们希望在一个 vector ,或者 list ,或者什么其他东西里面,找到一个值在哪个位置,这个时候 find 帮不上忙,而有人就转而求助手写循环了,而且是原始的手写循环:
for ( int i = 0; i     if ( vect == value ) break;

如果编译器把 i 看作 for scope 的一部分,你还要把 i 的声明拿出去。真的需要这样么?看看这个:

    int dist =         distance(col.begin(),             find(col.begin(), col.end(), 5));

其中 col 可以是很多容器,list, vector, deque... 当然这是你确定 5 就在 col 里面的情形,如果你不确定,那就加点判断:

    int dist;    list::iterator pos = find(col.begin(), col.end(), 5);    if ( pos != col.end() )        dist = distance(col.begin(), pos);

我想这还是比手写循环来的好些吧。

--------------------------------------------------------------------------
max, min
这是有直接的算法支持的,当然复杂度是 O(n),用于未排序容器,如果是排序容器...老兄,那还需要什么算法么?

max_element(col.begin(), col.end());min_element(col.begin(), col.end());

注意返回的是 iterator ,如果你关心的只是值,那么好:

*max_element(col.begin(), col.end());*min_element(col.begin(), col.end());
max_element 和 min_element 都默认用 less 来排序,它们也都接受一个 binary predicate ,如果你足够无聊,甚至可以把 max_element 当成 min_element 来用,或者反之:

*max_element(col.begin(), col.end(), greater()); // 返回最小值!*min_element(col.begin(), col.end(), greater()); // 返回最大值

当然它们的本意不是这个,而是让你能在比较特殊的情况下使用它们,例如,你要比较的是每个元素的某个成员,或者成员函数的返回值。例如:

#include #include #include #include #include using namespace boost;using namespace std;struct Person{    Person(const string& _name, int _age)        : name(_name), age(_age)    {}    int age;    string name;};int main(){    list col;    list::iterator pos;    col.push_back(Person("Tom", 10));    col.push_back(Person("Jerry", 12));    col.push_back(Person("Mickey", 9));    Person eldest =         *max_element(col.begin(), col.end(),             bind(&erson::age, _1) =1.33        cout }

输出是 Jerry ,这里用了 boost.bind ,原谅我不知道用 bind2nd, mem_fun 怎么写,我也不想知道...

-------------------------------------------------------------------------
copy_if
没错,STL 里面压根没有 copy_if ,这就是为什么我们需要这个:

templateOutputIterator copy_if(    InputIterator begin, InputIterator end, OutputIterator destBegin, Predicate p){    while (begin != end)     {        if (p(*begin))*destBegin++ = *begin;        ++begin;    }    return destBegin;}

把它放在自己的工具箱里,是一个明智的选择。

------------------------------------------------------------------------
惯用手法:erase(iter++)
如果你要去除一个 list 中的某些元素,那可千万小心:(下面的代码是错的!!!)

#include #include #include #include int main(){    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};    std::list lst(arr, arr + 10);    for ( std::list::iterator iter = lst.begin();          iter != lst.end(); ++iter)        if ( *iter % 2 == 0 )            lst.erase(iter);                std::copy(lst.begin(), lst.end(),        std:stream_iterator(std::cout, " "));}

当 iter 被 erase 掉的时候,它已经失效,而后面却还会做 ++iter ,其行为无可预期!如果你不想动用 remove_if ,那么唯一的选择就是:

#include #include #include #include int main(){    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};    std::list lst(arr, arr + 10);    for ( std::list::iterator iter = lst.begin();          iter != lst.end(); )        if ( *iter % 2 == 0 )            lst.erase(iter++);        else            ++iter;               std::copy(lst.begin(), lst.end(),        std:stream_iterator(std::cout, " "));}

但是上面的代码不能用于 vector, string 和 deque ,因为对于这些容器, erase 不光令 iter 失效,还令 iter 之后的所有 iterator 失效!

-------------------------------------------------------------------------
erase(remove...) 惯用手法
上面的循环如此难写,如此不通用,如此不容易理解,还是用 STL 算法来的好,但是注意,光 remove_if 是没用的,必须使用 erase(remove...) 惯用手法:

#include #include #include #include #include #include int main(){    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};    std::list lst(arr, arr + 10);    lst.erase(remove_if(lst.begin(), lst.end(),        boost::bind(std::modulus(), _1, 2) == 0),        lst.end()    );               std::copy(lst.begin(), lst.end(),        std:stream_iterator(std::cout, " "));}

当然,这里借助了 boost.bind ,让我们不用多写一个没用的 functor 。
*************
简单常识——关于stream
从文件中读入一行

简单,这样就行了:
ifstream ifs("input.txt");
char buf[1000];

ifs.getline(buf, sizeof buf);
string input(buf);
当然,这样没有错,但是包含不必要的繁琐和拷贝,况且,如果一行超过1000个字符,就必须用一个循环和更麻烦的缓冲管理。下面这样岂不是更简单?
string input;
input.reserve(1000);
ifstream ifs("input.txt");
getline(ifs, input);

不仅简单,而且安全,因为全局函数 getline 会帮你处理缓冲区用完之类的麻烦,如果你不希望空间分配发生的太频繁,只需要多 reserve 一点空间。
这就是“简单常识”的含义,很多东西已经在那里,只是我一直没去用。
---------------------------------------------------------------------------
一次把整个文件读入一个 string

我希望你的答案不要是这样:
string input;
while( !ifs.eof() )
{
    string line;
    getline(ifs, line);
    input.append(line).append(1, '/n');
}

当然了,没有错,它能工作,但是下面的办法是不是更加符合 C++ 的精神呢?
string input(
    istreambuf_iterator(instream.rdbuf()),
    istreambuf_iterator()
);

同样,事先分配空间对于性能可能有潜在的好处:
string input;
input.reserve(10000);
input.assign(
    istreambuf_iterator(ifs.rdbuf()),
    istreambuf_iterator()
);

很简单,不是么?但是这些却是我们经常忽略的事实。
补充一下,这样干是有问题的:
    string input;     input.assign(         istream_iterator(ifs),         istream_iterator()     );

因为它会忽略所有的分隔符,你会得到一个纯“字符”的字符串。最后,如果你只是想把一个文件的内容读到另一个流,那没有比这更快的了:

    fstream fs("temp.txt");     cout  
因此,如果你要手工 copy 文件,这是最好的(如果不用操作系统的 API):
   ifstream ifs("in.txt");    ofstream ofs("out.txt");    ofs  
-------------------------------------------------------------------------
open 一个文件的那些选项
ios::in     Open file for reading
ios::out    Open file for writing
ios::ate    Initial position: end of file
ios::app    Every output is appended at the end of file
ios::trunc  If the file already existed it is erased
ios::binary Binary mode
-------------------------------------------------------------------------
还有 ios 的那些 flag

flag
effect if set

ios_base::boolalpha
input/output bool objects as alphabetic names (true, false).

ios_base::dec
input/output integer in decimal base format.

ios_base::fixed
output floating point values in fixed-point notation.

ios_base::hex
input/output integer in hexadecimal base format.

ios_base::internal
the output is filled at an internal point enlarging the output up to the field width.

ios_base::left
the output is filled at the end enlarging the output up to the field width.

ios_base::oct
input/output integer in octal base format.

ios_base::right
the output is filled at the beginning enlarging the output up to the field width.

ios_base::scientific
output floating-point values in scientific notation.

ios_base::showbase
output integer values preceded by the numeric base.

ios_base::showpoint
output floating-point values including always the decimal point.

ios_base::showpos
output non-negative numeric preceded by a plus sign (+).

ios_base::skipws
skip leading whitespaces on certain input operations.

ios_base::unitbuf
flush output after each inserting operation.

ios_base::uppercase
output uppercase letters replacing certain lowercase letters.
There are also defined three other constants that can be used as masks:

constant
value

ios_base::adjustfield
left | right | internal

ios_base::basefield
dec | oct | hex

ios_base::floatfield
scientific | fixed
--------------------------------------------------------------------------

用我想要的分隔符来解析一个字符串,以及从流中读取数据

这曾经是一个需要不少麻烦的话题,由于其常用而显得尤其麻烦,但是其实 getline 可以做得不错:

    getline(cin, s, ';');        while ( s != "quit" )     {         cout          getline(cin, s, ';');     }

简单吧?不过注意,由于这个时候 getline 只把 ; 作为分隔符,所以你需要用 ;quit; 来结束输入,否则 getline 会把前后的空格和回车都读入 s ,当然,这个问题可以在代码里面解决。

同样,对于简单的字符串解析,我们是不大需要动用什么 Tokenizer 之类的东西了:

#include  #include  #include  using namespace std; int main() {     string s("hello,world, this is a sentence; and a word, end.");     stringstream ss(s);         for ( ; ; )     {         string token;         getline(ss, token, ',');         if ( ss.fail() ) break;                 cout      } }

输出:

hello world  this is a sentence; and a word  end.

很漂亮不是么?不过这么干的缺陷在于,只有一个字符可以作为分隔符。

--------------------------------------------------------------------------

把原本输出到屏幕的东西输出到文件,不用到处去把 cout 改成 fs

#include
#include  
using namespace std;
int main()
{     
    ofstream outf("out.txt");  
    streambuf *strm_buf=cout.rdbuf();     
    cout.rdbuf(outf.rdbuf());  
    cout

输出到屏幕的是:

display something on screen

输出到文件的是:

write something to file

也就是说,只要改变 ostream 的 rdbuf ,就可以重定向了,但是这招对 fstream 和 stringstream 都没用。

--------------------------------------------------------------------------

关于 istream_iterator 和 ostream_iterator

经典的 ostream_iterator 例子,就是用 copy 来输出:

#include  #include  #include  #include  #include  #include  using namespace std; int main() {       vector vect;     for ( int i = 1; i          vect.push_back(i);             copy(vect.begin(), vect.end(),         ostream_iterator(cout, " ")     );     cout          ostream_iterator os_iter(cout, " ~ ");     *os_iter = 1.0;     os_iter++;     *os_iter = 2.0;     *os_iter = 3.0; }

输出:

1 2 3 4 5 6 7 8 9 1 ~ 2 ~ 3 ~

很明显,ostream_iterator 的作用就是允许对 stream 做 iterator 的操作,从而让算法可以施加于 stream 之上,这也是 STL 的精华。与前面的“读取文件”相结合,我们得到了显示一个文件最方便的办法:

    copy(istreambuf_iterator(ifs.rdbuf()),          istreambuf_iterator(),          ostreambuf_iterator(cout)     );

同样,如果你用下面的语句,得到的会是没有分隔符的输出:

    copy(istream_iterator(ifs),          istream_iterator(),          ostream_iterator(cout)     );

那多半不是你要的结果。如果你硬是想用 istream_iterator 而不是 istreambuf_iterator 呢?还是有办法:

    copy(istream_iterator(ifs >> noskipws),          istream_iterator(),          ostream_iterator(cout)     );

但是这样不是推荐方法,它的效率比第一种低不少。
如果一个文件 temp.txt 的内容是下面这样,那么我的这个从文件中把数据读入 vector 的方法应该会让你印象深刻。

12345 234 567
89    10

程序:

#include  #include  #include  #include  #include  using namespace std; int main() {       ifstream ifs("temp.txt");         vector vect;     vect.assign(istream_iterator(ifs),
        istream_iterator()
    );     copy(vect.begin(), vect.end(), ostream_iterator(cout, " ")); }

输出:

12345 234 567 89 10

很酷不是么?判断文件结束、移动文件指针之类的苦工都有 istream_iterator 代劳了。

-----------------------------------------------------------------------

其它算法配合 iterator

计算文件行数:

    int line_count =         count(istreambuf_iterator(ifs.rdbuf()),               istreambuf_iterator(),               '/n');        

当然确切地说,这是在计算文件中回车符的数量,同理,你也可以计算文件中任何字符的数量,或者某个 token 的数量:

    int token_count =         count(istream_iterator(ifs),               istream_iterator(),               "#include");        

注意上面计算的是 “#include” 作为一个 token 的数量,如果它和其他的字符连起来,是不算数的。

------------------------------------------------------------------------
Manipulator

Manipulator 是什么?简单的说,就是一个接受一个 stream 作为参数,并且返回一个 stream 的函数,比如上面的 unskipws ,它的定义是这样的:

  inline ios_base&   noskipws(ios_base& __base)   {     __base.unsetf(ios_base::skipws);     return __base;   }

这里它用了更通用的 ios_base 。知道了这一点,你大概不会对自己写一个 manipulator 有什么恐惧感了,下面这个无聊的 manipulator 会忽略 stream 遇到第一个分号之前所有的输入(包括那个分号):

template
inline std::basic_istream&
ignoreToSemicolon (std::basic_istream& s)
{
    s.ignore(std::numeric_limits::max(), s.widen(';'));
    return s;
}
不过注意,它不会忽略以后的分号,因为 ignore 只执行了一次。更通用一点,manipulator 也可以接受参数的,下面这个就是 ignoreToSemicolon 的通用版本,它接受一个参数, stream 会忽略遇到第一个该参数之前的所有输入,写起来稍微麻烦一点:

struct IgnoreTo {
    char ignoreTo;
    IgnoreTo(char c) : ignoreTo(c)
    {}
};
   
std::istream& operator >> (std::istream& s, const IgnoreTo& manip)
{
    s.ignore(std::numeric_limits::max(), s.widen(manip.ignoreTo));
    return s;
}
但是用法差不多:

    copy(istream_iterator(ifs >> noskipws >> IgnoreTo(';')),          istream_iterator(),          ostream_iterator(cout)     );

其效果跟 IgnoreToSemicolon 一样。
 
c++在一个cpp文件中调用另一个cpp文件的函数的两种方法 有时候写代码为了简便,会将一些函数方法单独在一个cpp的源文件中定义,然后在另一个源文件中需要用到自定义的函数时直接调用就可以了!学过c++的人可能最熟悉的方法还是利用头文件来进行调用,其实还有一种c语言当中的方法一般情况下同样可以适用与c++中! 方法1:创建头文件 举个简单的例子: 首先创建一个method.h头文件,声明一个求最大值的函数max(int x,int y),然后再创建一个同名的源文件method.cpp,在该文件中实现函数max(int x,int y)的功能。代码如下: //metho 阅读详情

相关推荐

【C++】使用 yaml-cpp 库操作 YAML

配置文件有利于我们灵活配置工程,解决大量重复劳动,也方便调试。YAML 是一种人类可读的数据序列化格式,它使用缩进和特定的符号来表示数据结构。在本文中,我们将详细介绍如何在 C++ 中使用yaml-cpp库来解析和生成 YAML 格式的数据。

coco的专栏 4979

C++中的String的常用函数用法总结

一. string的构造函数的形式: string str:生成空字符串 string s(str):生成字符串为str的复制品 string s(str, strbegin,strlen):将字符串str中从下标strbegin开始、长度为strlen的部分作为字符串初值 string s(cstr, char_len):以C_string类型cstr的前char_len个字...

qq_37941471的博客 46万+

行为树基本概念与BehaviorTree.CPP库在C++的代码实现

文章介绍了行为树的基本概念以及介绍了MIT开源的行为树实现库——BehaviorTree.CPP的使用,包含部分C++的代码实现

Vulcan_Q的博客 5394

C++对string进行大小写转换的三种方法

C++对string进行大小写转换的三种方法。

2万+

【log4】c++日志工具之——log4cpp

1、log4cpp概述 Log4cpp是一个开源的C++类库,它提供了C++程序中使用日志和跟踪调试的功能,它的优点如下: 提供应用程序运行上下文,方便跟踪调试; 可扩展的、多种方式记录日志,包括命令行、文件、回卷文件、内存、syslog服务器、Win事件日志等; 可以动态控制日志记录级别,在效率和功能中进行调整; 所有配置可以通过配置文件进行动态调整; 多语言支持,包括Java(log4j),C++(log4cpp、log4cplus),C(log4c),python(...

我的笔记本 8057

C++ 网络库 cpp-netlib的简单使用

示例代码 (C++11, cpp-netlib版本:0.12.0) 需要链接库文件 target_link_libraries(app boost_system network-uri cppnetlib-server-parsers ) #include <network/uri.hpp> #include <nlohmann/json.hpp...

逗神大人的博客 6248

【C++中的string字符串常用函数】tolower(), toupper(), isalnum(), isdigit(), islower(), isupper(), isalpha()

【C++中的string字符串判断函数】tolower(), toupper(), isalnum(), isdigit(), islower(), isupper(), isalpha()

m0_48086806的博客 954

C++ Yaml文件解析安装及使用 yaml-cpp

C++ Yaml文件解析安装及使用安装 yaml-cpp克隆官方库编译 yaml-cpp示例代码robot.cpprobot.yaml编译 robot.cpp运行结果难点分析与总结什么是 .a 与 .so 文件静态链接库(.a) 与动态链接库(.so)静态链接库动态链接库g++(gcc)编译选项参考文章 安装 yaml-cpp 克隆官方库 git clone https://github.co...

Fourier_Legend的博客 2万+

Cpp入门基础

定义命名空间,需要使⽤到namespace关键字,后⾯跟命名空间的名字,然后接⼀对{}即可,{}中 即为命名空间的成员。命名空间中可以定义变量/函数/类型等。namespace本质是定义出⼀个域,这个域跟全局域各⾃独⽴,不同的域可以定义同名变量,所以下 ⾯的rand不在冲突了。C++中域有函数局部域,全局域,命名空间域,类域;域影响的是编译时语法查找⼀个变量/函数/ 类型出处(声明或定义)的逻辑,所有有了域隔离,名字冲突就解决了。

2401_86658278的博客 5500

用C++的类完成玩骰子的游戏

我们生活中随处可见的玩骰子游戏,那么我们用C++的类实现出来时会是怎么样呢?  首先,是得到一个1-6之间随机数的写法 Random.h#ifndef RANDOM__H__ #define RANDOM__H__using namespace std; #include <cstdlib> #include <ctime> class Random { public: Random();

心之所向,一如既往 2596

c++ 利用yaml-cpp读写yaml配置文件

在程序员的开发生涯中,读写配置文件必不可少。 配置文件有利于我们灵活配置工程,解决大量重复劳动,也方便调试。 配置文件的格式有很多,最简单的有一行一行的文本,也有像 json、xml、protocol buffer 这样结构化的格式,当然也有 yaml 这种格式。 今天的博文介绍的是如何在 C++ 开发中利用 yaml-cpp 开源库读写 yaml 配置文件。 如果有 Python 开发经验的同学,可能知道用 Python 读取 yaml 是再简单不过了,但是 C++ 麻烦一点,它需要你自己下载源码然后编译

newbeixue的博客 4044

C++中的 .h 和 .cpp 详解

通俗解释:.h和.cpp差不多就像书和目录的关系吧,目录中对书中的章节和内容进行简单表示,真正的实现是在书里面的。 一般的数据,数据结构,接口,还有类的定义放在.h文件中,可以叫他们头文件,可以#include 到别的文件中。功能实现一般都放在具体的.cpp文件中,这样方便文件管理,节约时间,提高效率。 你完全可以把功能实现一并放在.h文件中,也可以#include一个.cpp文件到另一个源文件中...

a063225的博客 2万+

C++(03):字符串转大/小写

tolower:用于转换为小写字符。toupper:用于转换为大写字符。

风静如云的博客 2241

C++ 在一个cpp文件中使用另一个cpp文件中定义的函数

C++ 在一个cpp文件中 使用另一个cpp文件中定义的函数建立一个console项目头文件cpp文件main.cpp 建立一个console项目 以dev为例,在【文件】【新建】【项目】,新建一个console项目。 头文件 添加新文件,输入说要使用函数的声明,保存为.h文件。 int add(int a,int b); cpp文件 定义在.h中声明的函数,保存为.cpp文件。 #include<iostream> #include"chen.h"//不要忘记这个 int a

m0_43456002的博客 9295

生态学家都在用的MixSIAR:用R语言搞定稳定同位素混合模型(从数据整理到结果解读)

本文详细介绍了生态学家常用的MixSIAR工具,通过R语言实现稳定同位素混合模型分析,从数据整理到结果解读全流程。文章涵盖环境准备、模型构建、参数设置、运行诊断及可视化等关键步骤,帮助研究者科学分析河口鱼类食物来源,适用于生态学研究和湿地保护政策制定。

weixin_28683065的博客 442

工业缺陷检测深度学习方法综述

异常:点异常、 上下文异常和集群异常。点异常:又称为离群值 (outliers)[9], 描述数值上偏离正 常样本的独立数据。与异常相近的概念还包括新颖点(novelty)和分布外数据。上下文异常:同样描述数据点,其数值属于正常范围,但不符合局部上下文规律。集群异常:描述一系列相关数据的集合,集合中的每一个实例的数值在单独考察时都处于正常值域,但集 合整体的相关性特征不服从正常模式。一般的图像异常检测往往仅需区分正常与异常样本,而工业缺陷检测更关注于检测 图像中的异常像素.

2301_80355452的博客 1850

c++ 开发中利用yaml-cpp读写yaml配置文件

在程序员的开发生涯中,读写配置文件必不可少。 配置文件有利于我们灵活配置工程,解决大量重复劳动,也方便调试。 配置文件的格式有很多,最简单的有一行一行的文本,也有像 json、xml、protocol buffer 这样结构化的格式,当然也有 yaml 这种格式。 今天的博文介绍的是如何在 C++ 开发中利用 yaml-cpp 开源库读写 yaml 配置文件。 如果有 Python 开发经验的同学...

frank 的专栏 6万+

在x86机器上运行jailhouse

jailhouse jaihouse提供了一个demo ,https://github.com/siemens/jailhouse-images可以用于编译一整套可用的demo。 适用于多个平台。编译过程主要参考https://blog.csdn.net/weixin_39541632/article/details/110422345 此demo可以生成多个平台所用的操作系统image。 ...

闲人的专栏 3007
上一篇: 项目经理与客户沟通的宜与忌
下一篇: 浅析软件项目进度管理中的积习流弊
binjuny
博客等级 码龄24年 112粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值