![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
支离破碎的梦灬
这个作者很懒,什么都没留下…
展开
-
编写一段程序,用cin读入一组字符串并把它们存入一个vector对象并输出
编写一段程序,用cin读入一组字符串并把它们存入一个vector对象string word; vector<string> text; // 空vector对象 while (cin >> word) { text.push_back(word); // 把word添加到text后面 } cout << "vector添加元素后为:" <&...原创 2019-11-25 21:40:01 · 1028 阅读 · 0 评论 -
使用引用形参返回额外信息
使用引用形参返回在string对象中某个指定字符第一次出现的位置。同时,返回该字符出现的总次数#include <iostream>#include <string>using namespace std;//返回s中c第一次出现的位置索引//引用形参occurs负责统计c出现的总次数int find_char(const string& s, ch...原创 2019-10-23 19:37:21 · 369 阅读 · 0 评论 -
C++ 插值排序
程序如下:#include using namespace std;int main(){int a[11]; // 让数组有一定存储空间int insertNum, i, j;cout << “输入数组:”;for (int i = 0; i < 10; i++){cin >> a[i];}cout << endl;cout &...转载 2019-07-02 20:37:28 · 485 阅读 · 0 评论 -
从键盘上输入若干个学生的成绩,当输入负数时表示输入结束,计算学生的平均成绩,并输出低于平均的学生成绩
#include <iostream>using namespace std;int main(){ double scores[8]; double sum = 0; double aveScores = 0; cout << "请输入学生成绩:" << endl; for (int i = 0; i < 8; i++) { cin...原创 2019-07-04 22:00:52 · 38293 阅读 · 5 评论 -
依次录入学生的成绩,并且判断有多少个分数高于或等于平均分,有多少个分数低于平均分。输入一个负数标志输入结束,假设最高分为100
#include <iostream>using namespace std;int main(){double scores[10]; double sum = 0; double aveScores = 0; int cnt1 = 0, cnt2 = 0; //cnt1用来判断高于或等于平均分的数量,cnt2用来判断低于平均分的数量 cout << "...原创 2019-07-05 20:50:43 · 4423 阅读 · 0 评论 -
编写一个用于在字符串中查找某字符的函数。输入源字符串和要查找的的字符,如果找到,显示字符在源字符串中的序号;如果找不到,显示“未找到”。
程序代码如下:#include <iostream>using namespace std;void chazhao(char *a, char s){ int cnt = 0; for (int i = 0; i < strlen(a); i++) { if (s == a[i]) { cnt++; cout << "您找的字符已找...原创 2019-07-11 21:50:12 · 1915 阅读 · 0 评论 -
error C4703: 使用了可能未初始化的本地指针变量“ptrCalc” VS2017
VS2017平台设置成x64还是win32,视 具体情况而定原创 2019-07-25 19:52:20 · 437 阅读 · 0 评论 -
编写一个函数,使用指针形参交换两个整数的值
#include <iostream>using namespace std;// 编写一个函数,使用指针形参交换两个整数的值。void exchange(int *p, int *q){ // 定义一个交换变量 int temp; // 交换 temp = *p; *p = *q; *q = temp; }int main(){ int i = 42,...原创 2019-07-31 20:28:22 · 8540 阅读 · 0 评论