cout

利用CPLD MAX3000系列EPM3064ALC44-10设计数字钟

匿名 (未验证) 提交于 2019-12-02 23:45:01
//实现二分频 module div2(cin,cout); input cin; output cout; reg cout; always@(posedge cin) begin cout<=~cout; end endmodule //十进制计数器 module counter10(rst,clk,dout,cout); input clk,rst; output cout; output[3:0] dout; reg cout; reg[3:0] dout; always@(posedge clk or posedge rst) begin if(rst) begin dout<=0; cout<=0; end else begin if(dout==4'd9) begin dout<=0; cout<=1; end else begin cout<=0; dout<=dout+1; end end end endmodule //六进制计数器 module counter6(rst,clk,dout,cout); input clk,rst; output cout; output[2:0] dout; reg cout; reg[3:0] dout; always@(posedge clk or posedge rst) begin if(rst) begin dout

sstream

匿名 (未验证) 提交于 2019-12-02 23:43:01
stringstream则是 初始化方法: stringstream stream; int a; stream << "12"; stream >> a; cout << a << endl; stringstream stream("adfaf afagfagag"); string a; stream >> a; cout << a << endl; string a = "aljfljfalf"; stringstream stream(a); cout << stream.str() << endl; 1 #include <sstream> 2 using namespace std; 3 int main() 4 { 5 stringstream stream; 6 int a,b; 7 stream << "080";//将“080”写入到stream流对象中 8 stream >> a;//将stream流写入到a中,并根据a的类型进行自动转换,"080" -> 80 9 cout << stream.str() << endl;//成员函数str()返回一个string对象,输出80 10 cout << stream.length() << endl;//2 11 } str()和clear() stream用完之后,其内存和标记仍然存在

C++11消息队列 + Qt线程池 + QRunnable执行任务简单模型

匿名 (未验证) 提交于 2019-12-02 23:42:01
1、模板类queue,包含头文件<queue>中,是一个FIFO队列。 queue.push():在队列尾巴增加数据 queue.pop():移除队列头部数据 queue.font():获取队列头部数据的引用... 2、Qt库的线程池,QThreadPool QThreadPool.setMaxThreadCount():设置线程池最大线程数 QThreadPool.start(new QRunnable(..)):开启线程池调用QRunnable 3、QRunnable执行任务 void run();//重写虚函数,在里面消费任务队列 setAutoDelete(true)//默认就是true,消费结束自动回收内存 4、代码 run.h #ifndef RUN_H #define RUN_H #include <QObject> #include <QRunnable> #include <string> #include <iostream> struct MyString { std::string valueStr; }; class Run : public QObject , public QRunnable { Q_OBJECT public: Run() = default; Run(const MyString& myString); protected:

C++ nth_element greater

匿名 (未验证) 提交于 2019-12-02 23:42:01
#include <iostream> #include <algorithm> #include <deque> #include <vector> #include <functional> #include <iterator> using namespace std; int main() {   deque<int> deq1;   deque<int>::iterator deq_iter1;   for (int k=0;k<16;k++)   {     deq1.push_back(rand());   }   for (deq_iter1 = deq1.begin();deq_iter1 != deq1.end();++deq_iter1)   {     cout << *deq_iter1 << " ";   }   cout << endl;   cout << "------------------------------"<<endl;   nth_element(deq1.begin(), deq1.begin() + 5, deq1.end());   for (deq_iter1 = deq1.begin(); deq_iter1 != deq1.end(); ++deq_iter1)   {     cout << *deq_iter1 <<

C++ STL 排序

匿名 (未验证) 提交于 2019-12-02 23:42:01
#include <iostream> #include <algorithm> #include <deque> #include <vector> #include <functional> #include <iterator> using namespace std; int main() {   deque<int> deq1;   deque<int>::iterator deq_iter1;   for (int k=0;k<16;k++)   {     deq1.push_back(rand());   }   for (deq_iter1 = deq1.begin();deq_iter1 != deq1.end();++deq_iter1)   {     cout << *deq_iter1 << " ";   }   cout << endl;   cout << "------------------------------"<<endl;   nth_element(deq1.begin(), deq1.begin() + 5, deq1.end());   for (deq_iter1 = deq1.begin(); deq_iter1 != deq1.end(); ++deq_iter1)   {     cout << *deq_iter1 <<

File Split 1.0

匿名 (未验证) 提交于 2019-12-02 23:40:02
1 #include <iostream> 2 #include <fstream> 3 #include <stdlib.h> 4 #include <string> 5 #include <windows.h> 6 7 using namespace std; 8 9 int main ( int argc, char* argv[] ) { 10 if ( argc != 4 && argc != 5 ) { 11 cout << "File Split 1.0" << endl; 12 cout << " Usage: fs <source file> <off begin> <off end> [<destination file>]" << endl; 13 cout << " e.g. fs app.exe 0 127 0_127.dat" << endl; 14 cout << " e.g. fs app.exe 0 127" << endl; 15 return -1; 16 } 17 fstream src ( argv[1], ios::in | ios::binary | ios::ate ); 18 if ( src.is_open() ) { 19 long long srcSize = static_cast<long long> ( src

c++:流与输入输出运算符的重载与

匿名 (未验证) 提交于 2019-12-02 23:38:02
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tonglin12138/article/details/91345106 写在前面: 问题: 解答: c++输入输出运算符的重载 # include <iostream> using namespace std ; class Distance { private : int feet ; // 0 到无穷 int inches ; // 0 到 12 public : // 所需的构造函数 Distance ( ) { feet = 0 ; inches = 0 ; } Distance ( int f , int i ) { feet = f ; inches = i ; } friend ostream & operator << ( ostream & output , const Distance & D ) { output << "F : " << D . feet << " I : " << D . inches ; return output ; } friend istream & operator >> ( istream & input , Distance & D ) { input >> D . feet >> D . inches ; return

C++中调用Tensorflow的pb文件(二)

匿名 (未验证) 提交于 2019-12-02 23:32:01
在之前的 博文 中有讲到如何编译安装c++版的Tensorflow,并简单调用自己训练的pb文件。在本文中将进一步结合代码调用pb文件。之前经常使用google发布在github上基于tensorflow的object detection模块,在该模块中官方事先提供了一系列预训练模型,如下图所示,我们可以直接使用这些模型也可以针对自己的项目进行re-train操作并得到最终的pb文件。 接下来我们在C++中调用这些模型,之前在网上找了好久都没找到可用的事例代码,而且官方提供的API看着也是一脸懵(编程菜鸟),后来摸索了很久总结代码如下: #include <iostream> #include "tensorflow/cc/ops/const_op.h" #include "tensorflow/cc/ops/image_ops.h" #include "tensorflow/cc/ops/standard_ops.h" #include "tensorflow/core/framework/graph.pb.h" #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/graph/default_device.h" #include "tensorflow/core/graph/graph

cin.width() &amp; cout.width()

匿名 (未验证) 提交于 2019-12-02 23:26:52
1. cin.width(n); 会把字符串全部读取,分成几块,每块n-1个字符,只输出第一块,如果字符串长度不满 n-1,剩下的用空格补齐; 从第n个字符开始到字符串不输出,输出时n-1个字符前边没有空格;同样也是只输出第一块 #include <iostream> using namespace std; int main(){ int width = 4; char str[20]; cout << "请输入一段文本: \n"; cin.width(5); //cin>>str;实际只能提取4个字符,str最后一个是空字符,其他的放在流中等待接受。 while( cin >> str ) { // cout.width(width++); //将4个字符输出,设置每次输出的域宽增加1 //cin >> str; cout << str << endl; //输出str cin.width(5); //设置接受4个字符 } return 0;} 结果: 2. cout.width(n); 输出n个字符,字符自动右对齐,左边用空格补上,视字符串中的空格为读取断开,即遇到空格时认为读取完了一块,在读取下一块,如果字符串长度大于n,则全部读取到下一个空格读完一块; #include <iostream> using namespace std; int main(){ int

What is the difference between std::cout and std::wcout?

帅比萌擦擦* 提交于 2019-12-02 23:24:46
In c++ what is the difference between std::cout and std::wcout ? They both control output to a stream buffer or print stuff to the console, or are they just alike ? They operate on different character types: std::cout uses char as character type std::wcout uses wchar_t as character type Otherwise both streams write to standard output. Another thing is that both are used with respected input stream. Objects of these are initialized during or before the first time an object of std::ios_base::Init is created. std::cout is std::basic_ios::tie 'd to std::cin and to std::cerr std:wcout is std::basic