2020年2月5日

vector容器

摘要: 1 /* 2 vec.begin() //指向迭代器中第一个元素。 3 vec.end() //指向迭代器中末端元素的下一个,指向一个不存在元素。 4 vec.push_back(elem) //在尾部加入一个数据。 5 vec.pop_back() //删除最后一个数据。 6 vec.capaci 阅读全文
posted @ 2020-02-05 10:47 yg02 阅读(98) 评论(0) 推荐(0) 编辑

容器排序

摘要: 1 #include<iostream> 2 #include<algorithm> //排序 3 #include<vector> //容器 4 using namespace std; 5 struct stu 6 { 7 int num; 8 int d; 9 int c; 10 int su 阅读全文
posted @ 2020-02-05 10:46 yg02 阅读(140) 评论(0) 推荐(0) 编辑

颜色

摘要: 1 /* 2 颜色函数SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),前景色 | 背景色 | 前景加强 | 背景加强); 3 前景色:数字0-15 或 FOREGROUND_XXX 表示 (其中XXX可用BLUE、RED、GREEN表示 阅读全文
posted @ 2020-02-05 10:44 yg02 阅读(185) 评论(0) 推荐(0) 编辑

绘图

摘要: 居中显示 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 void C(char S[80])//将参数(字符串)在屏幕上居中显示 5 { 6 int length; 7 int center; 8 length= 阅读全文
posted @ 2020-02-05 10:42 yg02 阅读(108) 评论(0) 推荐(0) 编辑

string

摘要: 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 string m="abc defg"; 7 //getline(cin,m); //输入带空格 阅读全文
posted @ 2020-02-05 10:40 yg02 阅读(87) 评论(0) 推荐(0) 编辑

输入

摘要: 输入未知个元素 1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 int main(){ 5 int n; 6 while(scanf("%d",&n)!=EOF){ //空格相间,回车结束 7 cout<<"This 阅读全文
posted @ 2020-02-05 10:38 yg02 阅读(138) 评论(0) 推荐(0) 编辑

math.h

摘要: 1 #include<math.h> 2 floor(x); //不大于x的最大整数 floor(x+0.5);四舍五入 3 ceil(x); //不小于x的最大整数 4 5 d=atan(x,y); //d为弧度 6 7 char a[10]; 8 double b=atof(a);//字符串转数 阅读全文
posted @ 2020-02-05 10:36 yg02 阅读(203) 评论(0) 推荐(0) 编辑

消字符缓存

摘要: 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 int main(){ 5 int n; 6 cin>>n; 7 cin.ignore(); 8 cin.get(); 9 getchar(); 10 return 0 阅读全文
posted @ 2020-02-05 10:34 yg02 阅读(108) 评论(0) 推荐(0) 编辑

输出格式

摘要: 1 #include<iostream> 2 #include<iomanip> 3 #include<stdio.h> 4 using namespace std; 5 int main(){ 6 double a; 7 while(cin>>a){ 8 cout<<setiosflags(ios 阅读全文
posted @ 2020-02-05 10:32 yg02 阅读(111) 评论(0) 推荐(0) 编辑

bugs

摘要: 1.换字符串输入方式 cin,cout超时换scanf,printf //&&&&&&& 2. cin>>n; cin.get(); //不能放入循环 while(n--){ cin.getline(c,51); } 3.数组是否够大//不要把长度定义正好 不要吝啬 4.数组定义的位置在循环内或外 阅读全文
posted @ 2020-02-05 10:28 yg02 阅读(210) 评论(0) 推荐(0) 编辑