stringstream的用法与例题(牛客“次佛锅”)

牛客OJ在线编程常见输入输出练习——自我复习 牛客OJ在线编程常见输入输出练习 对于像我一样的非科班来说,牛客的ACM模式对我们来说一开始应该是蒙圈的。 尤其是现在是春招、实习笔试的关键阶段,大家可是都要有输入输出处理的! 如果LeetCode刷了四五百道,结果不会输入输出,岂不是郁闷死(捂脸),在这里我发现了牛客的一个练习输入输出的地儿 链接在这里: 点击 OJ在线编程常见输入输出练习场. 然后我简单地做了一下,还是很有收获的,尤其是对于我这种菜鸟来说。 这里我参考了 NewsomTech的博客 这是链接 。毕 阅读详情

先看下例题吧:

https://ac.nowcoder.com/acm/contest/30532/Chttps://ac.nowcoder.com/acm/contest/30532/C

 

 如果你不会stringstream,可能就会想办法读入一行字符串,之后遇到空格就分类,没错,我就是这样写的,WA了一个半小时(水平不够吧),例如:

#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
using namespace std;
const int N=5e5+10;
string s;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
char aa[25],ab[15];
int main()
{
	IOS;
    getline(cin,s);
    ll n=s.length();
    ll tem=0,temp=0;
    map<string,long long>mp;
    for(ll i=0;i<n;i++)
    {	
		//cout<<s[i]<<endl; 
        if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
		    aa[tem++]=s[i];
		//cout<<aa<<endl;
		if(s[i]==' ') continue;
		if((s[i]>='0'&&s[i]<='9'))
    	{
    		ll num=0;
    		while((s[i]>='0'&&s[i]<='9'))
    		{
    			ab[temp++]=s[i];
    			i++;
			}
			for(int i=0;i<temp;i++)
			{
				num+=(ab[i]-'0')*pow(10,temp-i-1);
			}
    		//cout<<"num "<<num<<endl;
			//cout<<aa<<"aa"<<endl;
            //cout<<mp[aa]<<endl;
    		mp[aa]+=num;
    		//cout<<mp[aa]<<endl;
    		tem=0;
    		temp=0;
    		memset(ab,0,15);
    		memset(aa,0,25);
		}
		
	}
	ll t;
	cin>>t;
	while(t--)
	{
		char ss[25];
		cin>>ss;
		//ll flag=strlen(ss);
        //cout<<ss<<"bb"<<endl;
		cout<<mp[ss]<<endl;
	}
    return 0;
}

但是你要是会stringstream,这题就是随随便便简简单单的AC了,例如:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const int N=5e5+10;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	IOS; 
	string s,t,a;
	getline(cin,s);
	stringstream stream;
	stream<<s;
	while(stream>>t)
	{
		cout<<t<<endl;
		stream>>a;
		cout<<a<<endl;
	}
	return 0;
}

那么来说一下stringstream的简单用法

1.头文件:<sstream>

2.stringstream是负责输入和输出操作的

3.作用:

        3.1.用于数据转化:这里举一个例子(整型转字符串型)

#include <string>
#include <sstream>
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
using namespace std;
int main()
{
	ll a=1000;//定义一个整型变量 
	stringstream s;//定义一个stringstream变量 
	s<<a;//将整型的值输入给stringstream 
	string ans;//这里要定义一个字符串型来接收stringstream的传出的值 
	s>>ans;//stringstream的值传出给字符串型 
	cout<<"stringstream: "<<ans<<endl;//输出的答案为 stringstream: 1000 
	return 0;
}

        3.2.用于读入多字符串

#include <string>
#include <sstream>
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
using namespace std;
int main()
{
	stringstream s;//定义一个stringstream变量 
	s<<"first string "<<" "<<"is: ";
	s<<"you "<<"are a idiot!";
	cout<<s.str()<<endl;//输出的答案为first string  is: you are a idiot! 
	return 0;
}

3.3用于分隔读入的一行字符串(如例题)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const int N=5e5+10;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	IOS; 
	string s,t;
	//这里我们保证一下输入的一行字符串是一个字符串+空格+数字+一个字符串... 
	getline(cin,s);//输入一行含多类型的字符串 
	stringstream stream; //定义一个stringstream方便读入与输出 
	stream<<s; //把读入的一行多类型字符串赋给stream 
	while(stream>>t)//遇到一个字符串循环一次 
	{
		cout<<t<<endl;// 输出一个字符串 
		ll a;//定义一个整型变量存数字 
		stream>>a;//下一个stream的值给a 
		cout<<a<<endl;//输出这个数 
	}   
	return 0;
}

4.stringstream的清空:

        4.1.s.str("");

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const int N=5e5+10;
int main()
{
	stringstream s;//定义一个stringstream变量 
	s<<"first string "<<" "<<"is: ";
	s<<"you "<<"are a idiot!";
	cout<<s.str()<<endl;//输出的答案为first string  is: you are a idiot! 
    // 清空 sstream
    s.str("");
    s<<"new";
    cout<<s.str()<<endl;//输出的答案为new
	return 0;
}

        4.2.clear() ;

#include <sstream>
#include <iostream>
using namespace std;
 int main()
{
    stringstream s;
    int a,b;
    s<<"6666";//插入了字符串 
    s>>a;//转化为整型 
    cout<<a<<endl;
    //在进行多次类型转换前,必须先运行clear()
    s.clear();
    //插入bool值
    s<<false;//相当于零
    // 转换为int类型
    s>>b;
    cout<<b<<endl;
    return 0;
}

核心代码模式与ACM模式:编程竞赛与面试的输入输出选择指南 在算法学习和编程实践中,输入输出处理是程序员必须掌握的基础技能,它直接关系到程序的健壮性和与外部环境的交互能力。其原理在于程序通过标准输入流接收数据,经过程序逻辑处理,再通过标准输出流返回结果,这是所有可执行程序的基本工作模型。掌握不同的IO模式对于提升代码的工程化水平至关重要,尤其在处理边界条件、多组数据流和性能优化时。在技术面试和算法竞赛等应用场景中,这一基础能力直接决定了问题解决的效率和成功率。本文聚焦于核心代码模式和ACM模式这两种典型的编程环境,深入解析它们各自的特点、适用场景及相互转换技巧,其中 阅读详情

相关推荐

从北邮机试题解析优先队列:复数集合动态排序与自定义比较器实战

优先队列作为一种高效的数据结构,其核心原理基于堆(Heap)实现,能够在O(log n)时间内完成元素的插入与删除,并快速获取当前优先级最高的元素。这一特性使其在需要动态维护最值或特定顺序的场景中具有极高的技术价值,广泛应用于任务调度、实时系统、数据流处理(如求中位数)以及贪心算法等领域。本文通过一道经典的“复数集合”机试题,深入探讨了如何利用优先队列处理动态排序需求,并重点解析了当标准优先级规则无法满足业务逻辑时,如何通过自定义比较器来融合复数模长与插入顺序等多维条件,实现符合题意的混合特性队列。文章结合

weixin_30542079的博客 427

C/C++ FILE 和 fstream 用法详解

FILE 是C语言自带的文件操作结构体, fstream 是C++的文件操作类,两者使用都比较常见,且用法比较类似,再次记录。

a1367666195的博客 6352

2024秋招淘天算法岗笔试复盘:KMP、动态规划与机器学习考点精析

从KMP算法的next数组计算到动态规划的状态转移,再到机器学习中的评估指标,这些基础技术概念看似独立,却共同构成了算法岗位笔试的核心考点。理解它们的原理不仅能解决字符串匹配、最长递增子序列、模型过拟合等典型问题,更能帮助候选人在大规模数据场景下做出正确的复杂度优化和模型选择。在互联网大厂的技术招聘中,这些知识被灵活地应用于区间覆盖、带权序列优化、Transformer复杂度分析等真实题目中。本文基于2024年秋招阿里淘天算法岗第二批笔试的实战经历,系统复盘了笔试中的选择题与编程题,并给出了时间管理与备考建

weixin_34185512的博客 312

C++ 工程实践(7):iostream 的用途与局限

陈硕 (giantchen_AT_gmail) http://blog.youkuaiyun.com/Solstice  http://weibo.com/giantchen 陈硕关于 C++ 工程实践的系列文章: http://blog.youkuaiyun.com/Solstice/category/802325.aspx 陈硕博客文章合集下载: http://blog.youkuaiyun.com/Solstice/ar...

weixin_34219944的博客 1201

保姆级教程:用Python从UCI下载波士顿房价数据集,手把手跑通线性回归、岭回归和Lasso

本文提供了一份保姆级教程,详细讲解如何用Python从UCI下载波士顿房价数据集,并手把手实现线性回归、岭回归和Lasso回归模型。内容涵盖数据获取、清洗、特征分析到模型构建与评估的全流程,特别适合机器学习初学者掌握波士顿房价预测这一经典案例。

weixin_34254848的博客 476

STM32F103模拟SSI时序解析:实现高精度绝对式编码器位置读取

本文详细解析了如何在STM32F103微控制器上通过软件模拟SSI协议时序,实现高精度绝对式编码器的位置读取。文章从项目驱动出发,深入剖析了SSI通信原理、硬件电平转换连接、核心软件模拟代码实现及关键时序参数调试方法,并提供了使用示波器进行波形对齐与优化的实战指南,为成本敏感型工业控制与机器人项目提供了高性价比的解决方案。

weixin_29196315的博客 141

C/C++文件读写详解(二)(istringstream、ostringstream、stringstream)

1.#include &lt;sstream&gt;istringstream类描述:从流中提取数据,支持 &gt;&gt; 操作字符串可以包括多个单词,单词之间使用空格分开istringstream的构造函数原形:  istringstream::istringstream(string str);  #include &lt;fstream&gt; #include &lt;iostream&...

邦戈邦戈栗子的博客 2281

PCL 使用RANSAC拟合平面【2026最新版】

RANSAC拟合平面算法原理和实现流程详解以及最大迭代次数和内点期望概率的设置方法。最后再对拟合后的平面法向量与向量(1,1,1)进行定向。博客长期更新,最近一次更新时间为:2026年4月24日。

点云侠的博客 42万+

【C++11】特殊类设计/类型转换/IO流

【C++11】特殊类设计/类型转换/IO流

KL4180的博客 1301

Matlab:Matlab 软件学习之Matlab内置的各种系统的简介、案例应用(基于Simulink模糊控制仿真/二阶瞬态震荡电路案例)之详细攻略

选择左上角要编辑变量的图标,给定当前变量的论域Range,设置隶属函数类型type(八种隶属函数类型以供选择),最后选中某个隶属度函数(选中为红色),移动绘图区的每个隶属度函数的三个端点(竖向为权重)。(1)、首先在模糊规则编辑器左边选择一个输入变量,并选中它的一个语言值(隶属函数),然后编辑器右边选择一个输出变量,并选中它的一个语言值(隶属函数),然后将这种关系添加到模糊规则中。制定完成后,会形成模糊规则矩阵,系统会根据模糊输入量(如r1、r2),经过模糊规则(如45条),进而确定输出量(Y1、Y2)。

走向CTO之路 1122

Arcgis使用NDVI值遥感反演叶面积指数(LAI)

经验模型反演操作不难,主要是要多看文献,了解公式。本文中的公式我也不清楚是哪个作物的NDVI和LAI的关系(别人提供的),继续看文献整理吧。后续会在下面罗列更新一下主要公式。

所有专家都曾始于新手 8429

牛客训练赛41

A 因为Bob可以换翻一个硬币,除了n=m时的情况,都能弄出有正面的硬币情况 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t-...

weixin_40588429的博客 206

2026终极反反爬:Canvas/WebGL/字体指纹全维度伪装,应对浏览器检测实战指南

本文分享了2026年浏览器指纹检测现状及全维度伪装方案。当前反爬系统采用多维度联合指纹检测,重点针对硬件级(WebGL、Canvas)、系统级(字体、CPU)和行为级(鼠标移动)指纹。作者设计了一个独立的指纹伪装引擎,包含真实设备指纹库、指纹生成器和统一注入层,通过JS沙箱隔离实现伪装。核心方案包括:Canvas指纹通过真实设备渲染差异添加微偏移;WebGL指纹完整劫持上下文返回真实显卡参数;字体指纹劫持measureText方法模拟不同系统字体宽度。该方案实测可连续运行一个月零封号,解决了传统方法易被检测

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 923

牛客输入输出

题目1: 输入第一行表示几个行,接下来每行2个数字,输出累加 #include<iostream> using namespace std; int main() { int n,a,b; cin>>n; for(int i=0;i<n;i++) { cin>>a>>b; cout<<a+b<<endl; } return 0; }

qq_37297658的博客 561

2026华为OD机试 新系统真题题库目录|机考题库 + 算法考点详解

华为OD机试 新系统真题题库目录|机考题库 + 算法考点详解华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2026e卷,od机试,2026E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2026华为od,如何备战华为od,华为od算法,华为od手撕代码,华为OD机试2024年最新题库,

KJ.JK 4684

YOLOv11改进策略【Neck】| PRCV 2023,SBA(Selective Boundary Aggregation):特征融合模块,描绘物体轮廓重新校准物体位置,解决边界模糊问题

SBA 模块在医疗图像分割中具有重要作用,其设计出发点是解决图像中物体边界模糊以及融合特征时的冗余和不一致问题。

Limiiiing的博客 1942

【牛客题解】 ——整数中1出现的次数

整数中1出现的次数 思路一:迭代 class Solution { public: int NumberOf1Between1AndN_Solution(int n) { int count=0; for(int i=1;i<=n;i++) { int temp=i; while(...

Vicky_Cr的博客 265

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

C++从入门到精通(第八篇) :IO流

1. C语言的输入与输出 C语言中我们用到的最频繁的输入输出方式就是scanf ()与printf()。 scanf(): 从标准输入设备(键盘)读取数 据,并将值存放在变量中。printf(): 将指定的文字/字符串输出到标准输出设备(屏幕)。注意宽度输出和精度 输出控制。C语言借助了相应的缓冲区来进行输入与输出。如下图所示: 对输入输出缓冲区的理解: 1 .可以屏蔽掉低级I/O的实现,低级I/O的实现依赖操作系统本身内核的实现,所以如果能够屏蔽这部分的差 异,可以很容易写出可移植的程序。 2.可以

yin_ming_hui的博客 873

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

面向牛客的输入输出总结

面向牛客的输入输出总结int类1(典型)2(典型)3(典型)4567string12(重点)3(重点) 输入输出典型题链接 int类 1(典型) #include<bits/stdc++.h> using namespace std; int main() { int a,b; while(cin>>a>>b) { cout<<a+b<<endl; } } 2(典型) #include<

flytowns的博客 252

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

牛客:BM22 比较版本号

问题描述 解题思路 正则,使用'.'进行分割,然后使用结果数组进行判断,对于前导0,字符串转数字函数会自动处理掉。 stringstream,自己使用的是这个方法,使用getline进行分割,随后进行相互判断,因为两个版本号长度可能不同(用点分隔后的小段),所以在整体处理完后,需要特别处理剩余的。 ac代码 int compare(string version1, string version2) { // write code here istringstream is

A315776的博客 428

[牛客]关于输入输出(stringsteam)

对输入的字符串进行排序后输出 打开以下链接可以查看正确的代码 #include "bits/stdc++.h" using namespace std; int main() { vector<string> s; string str; while(getline(cin, str)) { stringstream ss(str); while(getline(ss, str, ',')) { s.empl

yinghui_yht的博客 339

【JZ73 翻转单词序列】

描述 牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上。同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思。例如,“nowcoder. a am I”。后来才意识到,这家伙原来把句子单词的顺序翻转了,正确的句子应该是“I am a nowcoder.”。Cat对一一的翻转这些单词顺序可不在行,你能帮助他么? 数据范围: 1 ≤ n ≤ 100 进阶:空间复杂度 O(n) ,时间复杂度 O(n) ,保证没有只包含空格的字符串 示例1 输

Sugar_wolf的博客 214

扑克牌-->牛客最搞心态的题目

#include #include #include #include #include using namespace std; #define B_KING 200 #define S_KING 100 bool isDoubleKing(vector& arr) { return arr[0] == S_KING && arr[1] == B_KING; } bool isDouble(vector& arr) { return arr[0] == arr[1]; }

ldbite的博客 179

比较版本号

牛客项目发布项目版本时会有版本号,比如1.02.11,2.14.4等等 现在给你2个版本号version1和version2,请你比较他们的大小 版本号是由修订号组成,修订号与修订号之间由一个"."连接。1个修订号可能有多位数字组成,修订号可能包含前导0,且是合法的。例如,1.02.11,0.1,0.2都是合法的版本号 每个版本号至少包含1个修订号。 修订号从左到右编号,下标从0开始,最左边的修订号下标为0,下一个修订号下标为1,以此类推。比较规则: 一. 比较版本号时,请按从左到右的顺序依次比较它们的修订

caoDanLife的博客 1155

别用itoa别用itoa别用itoa

#include #include using namespace std; int main() { int n = 123456; char p[100] = {}; stringstream s; s s >> p; cout system("pause"); return 0; } C++里stringstream 不能再好用,为啥要用那么差的itoa呢,牛

gouhexiong1989的博客 1万+

c++ 数字类型和字符串类型互转

一级标题 c++ 数字类型和字符串类型互转 @c++ 数字类型和字符串类型互转 一级目录 数字转为字符串 二级目录 字符串转为数字 1.数字转为字符串 (1).首先要加头文件 #include < iostream > #include < sstream > #include < string > 这个类在头文件中定义, < sstream>库定义了三种类:istringstream、ostringstream和string

qq_53336225的博客 286
上一篇: 并查集与ios::sync_with_stdio(false)加速
下一篇: 高精度运算
吴雨4
博客等级 码龄6年 7137粉丝 42原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值