标签:二维 空格 span dig code 基于 eof array 标准
for (int i = 0; i < 5; i++) { cout << "abc"<< endl; }
或
for (int i = 5; i; i--) { cout << "abc" << endl; }
int a = 0; while (a<10) { a++; cout << a << endl; }
int a = 0; do { a++; cout << a << endl; } while (a<5);
对数组或容器类 vector array
int a[] = { 3,6,8,7 }; for (int i:a) { cout << i << endl; }
能够修改数组内容
int a[] = { 3,6,8,7 }; for (int &i:a) { cout << i << endl; }
循环内初始化
for (int i: { 3,6,8,7 }) { cout << i << endl; }
1.使用原始cin输入
char ch; int count = 0; cout << "输入字符,按#结束"; cin >> ch; while (ch != ‘#‘) { cout << ch; ++count; cin >> ch; } cout << count << endl;
忽略了空格等字符
2.cin.get
char ch; int count = 0; cout << "输入字符,按#结束"; cin.get(ch); while (ch != ‘#‘) { cout << ch; ++count; cin.get(ch); } cout << count << endl;
包含空格等
3.EOF
int arr[3][3] = { {1,2,3},{4,5,6},{7,8,9} }; int c = 0; for (int i=0; i<3;i++) { for (int j = 0; j < 3;j++) { c = arr[i][j]; cout << c << endl; } }
if () { // } else if () { // } else { // }
|| &&
if (a> 0 && a<5) { // } if (a< 0 || a>5) { // }
#include<cctype> isalnum() //判断是否数字或字母 isalpha() //是否字母 iscntrl() //是否控制字符 isdigit() //是否0-9 isgraph() //是否除空格之外的打印字符 islower() //是否小写字母 isprint() //是否打印字符 ispunct() //是否标点符号 isspace() //是否标准空白字符(空格,进纸,换行,回车,制表) isupper() //是否大写字母 isxdigit() //是否十六进制 tolower() //如果是大写,返回小写 toupper() //如果是小写,返回大写
char ch = 1 > 3 ? ‘a‘ : ‘b‘; cout << ch;
char ch = ‘c‘; switch (ch) { case ‘a‘: case ‘A‘: cout << ch; break; default: cout << "off"; }
break 跳出该循环
continue 跳出本次循环
标签:二维 空格 span dig code 基于 eof array 标准
原文地址:https://www.cnblogs.com/buchizaodian/p/11521087.html