C++字符串输入函数小结

【C++学习笔记】数组的输入 字符串在C++中是特殊的存在(很多字符串函数,用字符串比用字符数组更方便,但是也导致字符串的使用方法和其他数组不同),因此在讨论数组问题是,都会把字符串单独拉出来说。 一、非字符串的输入方法 cin>>a[i]; 本语句用于将键盘输入的信息储存在a[i]中。 使用cin不需要向C语言一样需要指出数据的类型,cin会直接按照之前对数组的类型声明,将输入的数据按照声明的类型储存在数组中 阅读详情

做了一些字符串类型的题目,发现在字符串类型的题目中

如何进行输入输出是很重要的,查找资料的过程中看到了这篇博文

觉得写的很好,就给转过来了

以下为正文:



原创 http://hi.baidu.com/atomxu 转载请注明出处

看了网上有人写的,不是很全,而且还有几处错误,所以自己重新找了一下MSDN中的相关内容。


1. cin/wcin

标准C++输入流,有ANSI版本和宽字符版本,用法基本相同,不用多说,下面的例子是cerr,中间也用到了这两个输入函数。

Example
// iostream_cerr.cpp
// compile with: /EHsc
// By default, cerr and clog are the same as cout
#include <iostream>
#include <fstream>

using namespace std;

void TestWide( )
{
   int i = 0;
   wcout << L"Enter a number: ";
   wcin >> i;
   wcerr << L"test for wcerr" << endl;
   wclog << L"test for wclog" << endl;  
}

int main( )
{
   int i = 0;
   cout << "Enter a number: ";
   cin >> i;
   cerr << "test for cerr" << endl;
   clog << "test for clog" << endl;
   TestWide( );
}
Input
3
1
Sample Output
Enter a number: 3
test for cerr
test for clog
Enter a number: 1
test for wcerr
test for wclog

===========================

2. cin.get()

用来读入字符或字符串,可以设置读取的个数和终结字符,而且如下示例可以指定存放的精确位置。注意最后需要留一个位置用来存放'\0'。

Example
// basic_istream_get.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main( )
{
   char c[10];

   c[0] = cin.get( ); //读取一个字符,存入c[0]
   cin.get( c[1] ); //读取一个字符,存入c[1]
   cin.get( &c[2],3 );//读取3个字符,从c[2]开始存放,或遇到'\n'
   cin.get( &c[4], 4, '7' );//读取4个字符,从c[4]开始存放,或遇到'7'

   cout << c << endl;
}
Input
11
Output
11

=============================

3. cin.getline()

从标准输入读取一行,有下面两种重载,没有指定终结符时,实际上默认为'\n'。例子中&c[0]等于直接写c,这样写只是说明可以指定精确存放位置。

basic_istream& getline(
   char_type *_Str,
   streamsize _Count
);
basic_istream& getline(
   char_type *_Str,
   streamsize _Count,
   char_type _Delim
);

Example
// basic_istream_getline.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main( )
{
   char c[10];

   cin.getline( &c[0], 5, '2' );
   cout << c << endl;
}
Input
12
Output
1

==============================

4. getline()

从键盘读取一行,可以不指定终结符,默认为'\n',当然也可以像例子中指定空格。这个是string流,使用时需要包含头文件<string>,注意与前面的cin.getline()区别。

Example
// string_getline_sample.cpp
// compile with: /EHsc
// Illustrates how to use the getline function to read a
// line of text from the keyboard.
//
// Functions:
//
//    getline       Returns a string from the input stream.
//////////////////////////////////////////////////////////////////////

#pragma warning(disable:4786)
#include <string>
#include <iostream>

using namespace std ;

int main()
{
   string s1;
   cout << "Enter a sentence (use <space> as the delimiter): ";
   getline(cin,s1, ' ');
   cout << "You entered: " << s1 << endl;;
}
Input
test this
Sample Output
Enter a sentence (use <space> as the delimiter): test this
You entered: test

Requirements
Header: <string>

====================

5. gets()/_getws()

从标准输入流读取一行,结尾的换行符'\n'会被替换成'\0'。注意它不检查缓存大小,因此可能造成缓冲区溢出漏洞,尽量少用。

Get a line from the stdin stream.

char *gets(
   char *buffer
);
wchar_t *_getws(
   wchar_t *buffer
);

Example
// crt_gets.c

#include <stdio.h>

int main( void )
{
   char line[21]; // room for 20 chars + '\0'
   gets( line ); // Danger: No way to limit input to 20 chars.
                  // Much preferable: fgets( line, 21, stdin );
                  // but you'd have to remove the trailing '\n'
   printf( "The line entered was: %s\n", line );
}
Input
Hello there!
Output
The line entered was: Hello there!
Note that input longer than 20 characters will overrun the line buffer and almost certainly cause the program to crash.

==================

6.

从终端读取一个字符,有标准和宽字符两者,一组带回显,一组不带。注意返回值是int(或wint_t)

Get a character from the console without echo (_getch, _getchw) or with echo (_getche, _getwche).

int _getch( void );
wint_t _getwch( void );
int _getche( void );
wint_t _getwche( void );

Example
// crt_getch.c
// compile with: /c
/* This program reads characters from
* the keyboard until it receives a 'Y' or 'y'.
*/

#include <conio.h>
#include <ctype.h>

int main( void )
{
   int ch;

   _cputs( "Type 'Y' when finished typing keys: " );
   do
   {
      ch = _getch();
      ch = toupper( ch );
   } while( ch != 'Y' );

   _putch( ch );
   _putch( '\r' );    /* Carriage return */
   _putch( '\n' );    /* Line feed       */
}
Input
abcdey
Output
Type 'Y' when finished typing keys: Y

============================

7.

从流(getc, getwc)或者标准输入(getchar, getwchar)读取一个字符,有标准和宽字符两种版本,返回值也是int(或wint_t)。

Read a character from a stream (getc, getwc), or get a character from stdin (getchar, getwchar).

int getc(
   FILE *stream
);
wint_t getwc(
   FILE *stream
);

int getchar( void );
wint_t getwchar( void );

Example
// crt_getc.c
/* This program uses getchar to read a single line
* of input from stdin, places this input in buffer, then
* terminates the string before printing it to the screen.
*/

#include <stdio.h>

int main( void )
{
   char buffer[81];
   int i, ch;

   /* Read in single line from "stdin": */
   for( i = 0; (i < 80) && ((ch = getchar()) != EOF)
                        && (ch != '\n'); i++ )
      buffer[i] = (char)ch;

   /* Terminate string with null character: */
   buffer[i] = '\0';
   printf( "Input was: %s\n", buffer );
}
Input
This is a test
Output
Input was: This is a test

=============================

8.

从文件流中读取一个字符串,直到遇到换行符,而且换行符也会被读入,并且不会自动转换为'\0';或者读入n-1个字符后自动添加一个'\0',有标准和宽字符两种版本。

Get a string from a stream.

char *fgets(
   char *string,
   int n,
   FILE *stream
);
wchar_t *fgetws(
   wchar_t *string,
   int n,
   FILE *stream
);

Example
// crt_fgets.c
/* This program uses fgets to display
* a line from a file on the screen.
*/

#include <stdio.h>

int main( void )
{
   FILE *stream;
   char line[100];

   if( (stream = fopen( "crt_fgets.txt", "r" )) != NULL )
   {
      if( fgets( line, 100, stream ) == NULL)
         printf( "fgets error\n" );
      else
         printf( "%s", line);
      fclose( stream );
   }
}
Input: crt_fgets.txt
Line one.
Line two.
Output
Line one.

===========================

9.

从流(fgetc, fgetwc)或者标准输入(_fgetchar, _fgetwchar)读取一个字符,有标准和宽字符两种版本。前一组以文件指针作为参数,后一组没有参数。

Read a character from a stream (fgetc, fgetwc) or stdin (_fgetchar, _fgetwchar).

int fgetc(
   FILE *stream
);
wint_t fgetwc(
   FILE *stream
);
int _fgetchar( void );
wint_t _fgetwchar( void );

Example
// crt_fgetc.c
/* This program uses getc to read the first
* 80 input characters (or until the end of input)
* and place them into a string named buffer.
*/

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
   FILE *stream;
   char buffer[81];
   int i, ch;

   /* Open file to read line from: */
   if( (stream = fopen( "crt_fgetc.txt", "r" )) == NULL )
      exit( 0 );

   /* Read in first 80 characters and place them in "buffer": */
   ch = fgetc( stream );
   for( i=0; (i < 80 ) && ( feof( stream ) == 0 ); i++ )
   {
      buffer[i] = (char)ch;
      ch = fgetc( stream );
   }

   /* Add null to end string */
   buffer[i] = '\0';
   printf( "%s\n", buffer );
   fclose( stream );
}
Input: crt_fgetc.txt
Line one.
Line two.
Output
Line one.
Line two.

==============================

10.

C语言继承来的,从标准输入流读取格式化数据,输入格式必须与设置的格式完全相同,示例如下。

Read formatted data from the standard input stream.

int scanf(
   const char *format [,
   argument]...
);
int wscanf(
   const wchar_t *format [,
   argument]...
);

Example
// crt_scanf.c
/* This program uses the scanf and wscanf functions
* to read formatted input.
*/

#include <stdio.h>

int main( void )
{
   int   i, result;
   float fp;
   char c, s[81];
   wchar_t wc, ws[81];
   result = scanf( "%d %f %c %C %80s %80S", &i, &fp, &c, &wc, s, ws );
   printf( "The number of fields input is %d\n", result );
   printf( "The contents are: %d %f %c %C %s %S\n", i, fp, c, wc, s, ws);
   result = wscanf( L"%d %f %hc %lc %80S %80ls", &i, &fp, &c, &wc, s, ws );
   wprintf( L"The number of fields input is %d\n", result );
   wprintf( L"The contents are: %d %f %C %c %hs %s\n", i, fp, c, wc, s, ws);
}
Input
71 98.6 h z Byte characters
36 92.3 y n Wide characters
Output
The number of fields input is 6
The contents are: 71 98.599998 h z Byte characters
The number of fields input is 6
The contents are: 36 92.300003 y n Wide characters

=================

11.

从字符串读取格式化数据,字符串必须已经存在。使用时最好指定字符串宽度,否则,不正常的输入格式容易发生错误。

Read formatted data from a string.

int sscanf(
   const char *buffer,
   const char *format [,
   argument ] ...
);
int swscanf(
   const wchar_t *buffer,
   const wchar_t *format [,
   argument ] ...
);

Example
// crt_sscanf.c
/* This program uses sscanf to read data items
* from a string named tokenstring, then displays them.
*/

#include <stdio.h>

int main( void )
{
   char tokenstring[] = "15 12 14...";
   char s[81];
   char c;
   int   i;
   float fp;

   /* Input various data from tokenstring: */
   sscanf( tokenstring, "%80s", s ); // max 80 character string
   sscanf( tokenstring, "%c", &c );
   sscanf( tokenstring, "%d", &i );
   sscanf( tokenstring, "%f", &fp );

   /* Output the data read */
   printf( "String    = %s\n", s );
   printf( "Character = %c\n", c );
   printf( "Integer: = %d\n", i );
   printf( "Real:     = %f\n", fp );
}
Output
String    = 15
Character = 1
Integer: = 15
Real:     = 15.000000

Security Note: When reading a string with sscanf, always specify a width for the %s format (for example, "32%s" instead of "%s"); otherwise, improperly

formatted input can easily cause a buffer overrun.

=======================

12.

从文件输入流读取格式化数据,输入格式必须与设置的格式完全相同,示例如下。

Read formatted data from a stream.

int fscanf(
   FILE *stream,
   const char *format [,
   argument ]...
);
int fwscanf(
   FILE *stream,
   const wchar_t *format [,
   argument ]...
);

Example
// crt_fscanf.c
/* This program writes formatted
* data to a file. It then uses fscanf to
* read the various data back from the file.
*/

#include <stdio.h>

FILE *stream;

int main( void )
{
   long l;
   float fp;
   char s[81];
   char c;

   stream = fopen( "fscanf.out", "w+" );
   if( stream == NULL )
      printf( "The file fscanf.out was not opened\n" );
   else
   {
      fprintf( stream, "%s %ld %f%c", "a-string",
               65000, 3.14159, 'x' );
      // Security caution!
      // Beware loading data from a file without confirming its size,
      // as it may lead to a buffer overrun situation.
      /* Set pointer to beginning of file: */
      fseek( stream, 0L, SEEK_SET );

      /* Read data back from file: */
      fscanf( stream, "%s", s );
      fscanf( stream, "%ld", &l );

      fscanf( stream, "%f", &fp );
      fscanf( stream, "%c", &c );

      /* Output data read: */
      printf( "%s\n", s );
      printf( "%ld\n", l );
      printf( "%f\n", fp );
      printf( "%c\n", c );

      fclose( stream );
   }
}
Output
a-string
65000
3.141590
x

============the end====================


详解C++字符串函数与字符数组附带例题 本文介绍了C++中字符串的基本概念和常用操作。主要内容包括:1)字符型与字符串型的区别;2)字符串的两种存储方式(char数组和string);3)字符串的输入输出方法;4)常用的字符串处理函数如strlen、strcpy、strcmp、strcat等;5)提供了5个字符串处理实例,涵盖字符统计、大小写分离、单词计数和卡牌游戏等应用场景。文章通过代码示例详细说明了字符串的定义、读取、比较和连接等操作,适合初学者学习C++字符串处理的基础知识。 阅读详情

相关推荐

基于远程服务器 Tip_Adapter源码从零开始复现

从零一步步实现源代码的运行

zcyzcyjava的博客 1608

使用wcout,wcin打印,输入中文宽字符

wcout,wcin在打印输入中文时会出现不显示与乱码问题。

weixin_62393907的博客 1175

【backtrader保姆级教学】投资组合回测

method1:探索投资组合的最有方案,使用蒙特卡洛模拟Markowitz模型。# 提取最小波动组合对应的权重, 并转换成Numpy数组。# 绘制收益-标准差的散点图,并用颜色描绘夏普比率。# 在收益-风险散点图中突出风险最小的点。:param any_day: 任意日期。# 将该点坐标显示在图中并保留四位小数。password = “替换密码”# 找到标准差最小数据的索引值。user = “替换账号”# 计算GMV投资组合收益。# 计算每项资产的夏普比率。# 设置无风险回报率为0。

weixin_38132951的博客 2323

wstring wcin wcout 汉字字符串

想从控制台输入含汉字字符串到wstring(按unicode字符集存储),问题如下: wstring wstr1 = L"李66"; wstring wstr2; wcin >> wstr2; //输入 李66 wstr2汉字“李”成了二个乱码! 二者内存中的数据: wstr1 : 4e 67 36 00 36 00 wstr2 : co 00 ee 00 36 00 36 00

u010634308的专栏 2612

【异常】Milvus 向量数据库字段缺失错误分析与解决 MilvusVectorStoreServiceV2 - Failed to insert batch [0-1]: The field:

本文分析了Milvus向量数据库插入操作中出现的字段缺失错误。错误显示age_mode字段未提供,导致批量插入失败。根本原因是Milvus Schema要求所有定义字段必须存在,但代码中对部分字段采用条件添加方式。解决方案是将条件添加改为始终添加,为可能为null的字段提供空字符串默认值。文章总结了Schema约束、防御性编程等经验,并建议通过Schema变更检查、单元测试覆盖和数据校验层等预防措施避免类似问题。该问题影响product、mac、source等多个字段,修改后确保了数据插入的可靠性。

奶爸的编程之路,也就一周冷个三天 427

面试问题总结——关于YOLO系列(三)

接着上篇的的YOLO系列面试问题总结,加油,冲! 三.YOLOv3 1.YOLOv3主干网络BackBone——Darknet-53网络结构(因为有53个卷积层) (原论文中Darknet53的尺寸是在图片分类训练集上训练的,所以输入的图像尺寸是256x256,而在YOLOv3中输入尺寸是416×416)   ①上图中,Top-1 Accuracy和Top-5 Accuracy是指什么呢?区别在哪呢?   我们知道ImageNet有大概1000个分类,而模型预测某张图片时,会给出1000个按概率从高.

boss-dog 1万+

C++设计缺陷 : cin/cout wcin/wcout

    首先声明,我热爱C++,因为我喜欢它强大的功能,别的语言有的它几乎都有。对于模板地各种使用更是让我觉得打开了新世界的大门。     然而它并不完美,甚至很多方面让人崩溃。我会把使用中的遇到的问题记录在这篇文章中。       绝大多数学C++的人第一堂课都会用到cin 和cout,但你永远想不到,当cin、cout与win、wcout一起用时会有多让人难过。也许是我造诣不够。我尝试使用...

Fq_Sl的博客 3928

Go基础:Go语言详细介绍,环境搭建,及第一个程序详解

Go语言是Google开发的开源编程语言,具有高效、简洁、并发性强等特点。文章从Go语言的诞生背景、核心特性及应用领域展开介绍,并详细说明了Windows、Linux和macOS下的环境搭建步骤,包括安装、环境变量配置及测试方法。最后通过“Hello, World!”程序解析Go语言基本语法,并演示了编译发布和跨平台编译功能。全文涵盖了Go语言从入门到实践的完整流程,适合初学者快速上手。

数据知道的博客 6806

(笔记)C++对于中英混合字符串的处理

使用wstring处理中英混合字符串 并解决乱码问题 以及wstring和string的相互转化

qq_54941014的博客 2420

2024全国村级行政边界数据

五级行政区划:村边界数据产品涵盖五级行政区划:(一级行政区)省级行政区共31个其中:(台湾、香港、澳门除外);(二级行政区)地级行政区共334个其中:7个地区、3个盟、30个自治州、294个地级市;(三级行政区)县级行政区共2851个其中:1355个县、117个自治县、49个旗、3个自治旗、363个县级市、962个市辖区、1个林区、1个特区;(四级行政区)乡级行政区共40497个其中:11626个乡、1034个民族乡、20117个镇、7566个街道、151个苏木、1个民族苏木、2个县辖区公所;

J_Giser的博客 3255

ROS2 多机器人导航仿真入门教程(一)

RMF 是建立在 ROS 2 基础上的一系列可重复使用、可扩展的库和工具,可实现任何类型机器人系统的异构机群的互操作性。RMF 利用标准化的通信协议与部署机器人的基础设施、环境和自动化系统进行通信,以优化关键资源(如机器人、电梯、门、通道等)的使用。它通过资源分配和通过 RMF 核心(将在本书后面详细介绍)防止共享资源冲突,从而为系统增加智能。RMF 灵活而强大,几乎可以在任何通信层上运行,并与任何数量的物联网设备集成。RMF 的架构设计允许随着环境自动化水平的提高而扩展。

2506_90492529的博客 1662

C++中cin、cin.get()、cin.getline()、getline()等函数的用法

学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行) 1、cin&amp;amp;nbsp; 2、cin.get()&amp;amp;nbsp; 3、cin.getline()&amp;amp;nbsp; 4、getline()&amp;amp;nbsp; 5、gets()&amp;amp;nbsp; 6、getchar() 附:cin.i

黄白柴柴的code之旅 214

ISO2626 --- Item Definition相关项定义

本文并不是针对ISO26262的一个项目,而是针对ISO26262的规范,我们在相关项定义阶段,我们需要做什么,我们的文档需要包含哪些内容的一个描述。

wj博客 914

C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法

C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法 学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行) 1、cin  2、cin.get()  3、cin.getline()  4、getline()  5、gets()...

因每天学习而伟大 251

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

C++输入一行字符串的一点小结

C++输入一行字符串的一点小结   原文链接: http://www.wutianqi.com/?p=1181   大家在学习C++编程时,一般在输入方面都是使用的cin. 而cin是使用空白(空格,制表符和换行符)来定字符串的界的。 这就导致了对于带有空格的字符串,比如”I Love C++奋斗乐园论坛” 只能读入”I”,后面的都无法读入。 这时怎么办?

码海坐标 1538

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

C++输入字符串小结

C++中常用的几种输入字符串的方式 cin、cin.get()、cin.getline()、getline()、gets()、getchar() https://blog.csdn.net/u011486738/article/details/82082405 字符串分割提取小结 使用sscanf()提取数据时,最好不要用string类型接收: string input, name; input = "1234 +abc"; sscanf(&input[0],"..

reason的博客 263

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

C++ 输入输出方式小结

输入方式支持的内容用法示例返回值cin >>整数、浮点数、字符、字符串cin >> a;istream&,判断输入成功cin.get()单个字符、字符数组cin.get(c);istream&,判断输入成功字符数组(带 ‘\0’ 结尾)istream&,判断输入成功getline()string字符串istream&,判断输入成功scanf()格式化读取整数、浮点数、字符、字符串读取的输入项数量getchar()单个字符读取的字符,EOF 返回 -1输出方式支持的内容用法示例返回值。

ailbj的博客 2221

C++字符串流stringstream与string知识介绍与用法小结

之前总结了C++的文件输出输入流的相关知识,通过介绍底层的streambuf缓冲区,从而与stringstream流(字符串流)联系了起来,本文就对此进行简单的介绍。 首先介绍string。 string 是 C++ 提供的字符串类,和 C 类型的字符串相比,除了有不限长度的优点外,还有其他许多方便的功能,其可以看成类似STL里vector数组的一种容器,可以方便的进行数据的增删改查,并可以进行...

不想不努力的博客 3万+

C++ 常用输入输出函数小结

  C++中用于输入和输出的函数很多,不同的输入输出函数之间功能上的细微区别有时会让初学者摸不着头脑,本文主要是对这些输入输出函数的小结,同时也是防止自己忘记.首先我们先明确缓冲区的概念. 一. 缓冲区 1. 什么是缓冲区   缓冲区(缓存)是内存中预留的一部分存储空间,这些空间用来缓存输入或者输出的数据.根据其对应的输入还是输出设备,可以分为输入缓冲区和输出缓冲区. 2. 为什么要引入缓...

Mymiku424的博客 1000

C/C++中字符串拼接的使用详解(加常见字符串使用小结)

C/C++中针对字符串函数的使用过程中,需要格外注意字符串终止符'\0'。字符串结尾处默认带'\0'。 带形参n的库函数可以有效防止因字符串长度过长导致的段错误,建议使用带n的字符串函数。一 、snprintf函数的使用字符串复制是别样的一种字符串拼接方式,通过将目标字符串复制到源字符串结尾处实现字符串拼接效果。int snprintf(char *str, size_t size, const char *format, ...)设将可变参数(...)按照 format 格式化成字符串,并将字符串复制到

qq_39645539的博客 3万+

C++ 字符串 string 类成员函数与方法 小结

介绍,常见的 字符串 string 类方法:插入,查找,替换,删除,添加,等还有一点是其要与链表联系起来!

稚枭天卓 9696

c++字符串输入小结

一.对于字符数组: 方法一:getline() 读入整行数据,它使用回车键输入的换行符来确定输入结尾。 调用方法: cin.getline(str, len); 第一个参数str是用来存储输入行的数组名称,第二个参数len是要读取的字符数。 1 2 3 4 5 6 7 8 9 10 #include using namespace

tzheng2008的专栏 1989

C++里string类字符串输入的用法

学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行) 1、cin 2、cin.get() 3、cin.getline() 4、getline() 5、gets() 6、getchar() 附:cin.ignore();cin.get();//跳过一个字符,例如不想要的回车,空格等字符 1、cin>> 用法1:最基本,也是最常用的用法,输入一个数字...

zengyujing的博客 4021
上一篇: uva--10474-- Where is the Marble?
下一篇: hud--1008--Elevator
acm_lkl
博客等级 码龄13年 114粉丝 319原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值