![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
southgirl00
这个作者很懒,什么都没留下…
展开
-
全局变量的使用
#include using namespace std;void MultiplyNumbers (){ cout int firstNumber = 0; cin >> firstNumber; cout int secondNumber = 0; cin >> secondNumber; // Multipl原创 2018-03-23 11:59:34 · 157 阅读 · 0 评论 -
从ROOT的histgraph中读取直方图转成txt格式
#include <iostream>#include <fstream>using namespace std;void root2txt(const char *rootfilename,const char *txtfilename){ TFile *file = new TFile(rootfilename,"READ");//"RECREATE" "...原创 2019-06-28 16:24:19 · 1391 阅读 · 0 评论 -
ifstream读取和ofstream写入
#include <iostream>#include <fstream>using namespace std;int main(){ ofstream myfile; const int nline=9; int num[nline]={1,2,3,4,5,6,7,8,9}; double data[nline]={1,2,3,5,4,12,45...原创 2018-05-16 18:34:35 · 1194 阅读 · 3 评论 -
map的简单用法
#include<map>#include<iostream>using namespace std;int main(){ map<int,int>m; int i; for(i=0;i<10;i++) m[i]=2-i; map<int,int>::iterator it; for(it=m....原创 2018-05-15 16:04:04 · 144 阅读 · 0 评论 -
使用std::stringstream对字符串进行转换
要包含头文件#include<sstream>#include<fstream>#include<sstream>#include<iostream>using namespace std;int main(){ cout << "Enter an integer: "; int input = 0; cin...原创 2018-05-18 10:37:01 · 2104 阅读 · 0 评论 -
寻峰 find peaks
#include "TCanvas.h"#include "TH1.h"#include "TF1.h"#include "TRandom.h"#include "TSpectrum.h"#include "TVirtualFitter.h" Int_t npeaks = 30;Double_t fpeaks(Double_t *x, Double_t *par) {原创 2018-05-18 00:10:26 · 5481 阅读 · 2 评论 -
类和对象
1.包含初始化参数的默认构造函数,并使用初始化列表设置成员#include <iostream>#include <string.h>using namespace std;class Human{private: int age; string name;public: Human(string humansName = "Adam",...原创 2018-05-12 14:57:41 · 109 阅读 · 0 评论 -
指针
1.声明和初始化int指针的代码:int *Pinteger = NULL;2.使用指针存储变地址:int Age=30;int *Ip=&Age;3.同一个int指针可指向任何int变量4.dec是十进制 如cout<<dec<<b 就会把b转换成10进制再输出hex是16进制 如cout<<dec<<b 就会把b转换成16进制再输出o...原创 2018-05-01 14:48:20 · 120 阅读 · 0 评论 -
if语句检查数组容量
将字符串复制到字符数组中,务必检查数组是否足够大,检查数组的容量。#include <iostream>#include <string>#include <string.h>using namespace std;int main(){char buffer[20]={'\0'};cout << "Enter a line of text: " &...原创 2018-04-11 19:15:53 · 314 阅读 · 0 评论 -
使用枚举常量
通过使用枚举常量,代码的可读性更强#include <iostream>using namespace std;enum CardinalDirections{ North = 25, South, East, West};int main(){ cout << "Displaying directions and their symbolic values...原创 2018-04-03 21:54:16 · 299 阅读 · 0 评论 -
字符串
字符串字面值与标准库string不是同一种类型string s("hello");cout<<s.size()<<endl; //OKcout<<"hello".size()<<endl; //ERRORcout<<s+"world"<<endl;转载 2018-04-03 21:16:46 · 67 阅读 · 0 评论 -
保存mca格式
TH1I *hspec1[4*NPAR]; for (int i = 0; i < 4*NPAR; ++i) { hspec1[i] = new TH1I(TString::Format("adj%02d",i+1).Data(),"",65536,0,65536); }for (int i = 0; i < 4*NPAR; ++i) { ...原创 2019-09-16 11:00:43 · 291 阅读 · 0 评论