我的学习记录33
来源:互联网 发布:gta5亚洲美女捏脸数据 编辑:程序博客网 时间:2024/05/21 21:02
2017.11.12李锦浩【第33天】
今天练习了编辑文本的程序练习,面对关于字符串的练习,我已经有了比较深刻的了解和应用。另外我今天还学了关于链表的相关知识,知道了链表里的结点可以用于连接其他数组的一种有效的方式,但是我对其中的一些具体的操作方式还不是很了解,明天要继续学习。
附:编辑文本程序练习:
//biaotou.h
#pragma once
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
void charu(string &s,string &t)
{
cout << "请选择插入目标,1表示插入至某一个字符前,2表示插入至某段之前"<< endl;
int x,y;
cin >> x;
if (x == 1)
{
cin >> y;
cout << "请输入所要插入的字符序号"<< endl;
t.insert(y, s);
cout << s << endl;
}
if (x == 2)
{
t += s;
cout << t << endl;
}
}
void shanchu(string &s)
{
cout << "请选择需要删除的字符数量,1表示删除所有,2表示删除一定数量"<< endl;
int x, y;
cin >> x;
if (x == 1)
{
cout << "请选择是否返回,1表示返回,2表示不返回"<< endl;
cin >> y;
if (y == 1)
{
s.erase();
}
if (y == 2)
{
s.clear();
}
}
if (x == 2)
{
cout << "请选择删除字符的数量以及删除起始对象"<< endl;
int z;
cin >> y>>z;
s.erase(z, y);
}
cout << s << endl;
}
void tihuan(intt, int m, string &s,string a)
{
s.replace(t,m, a);
}
void chazhao(string &s)
{
cout << "请输入查找对象"<< endl;
char *c;
c = new char[64];
gets_s(c, 64);
string s1;
s1 = c;
s.find(s1);
delete []c;
c = NULL;
}
//yuan.cpp
#include<iostream>
#include"标头.h"
#include<cstdio>
using namespace std;
int main()
{
cout << "请输入文本"<< endl;
char *b;
b = new char[500];
gets_s(b, 500);
string s;
s = b;
cout << "请选择对文本的操作,1表示插入,2表示删除,3表示替换,4表示查找,5退出程序"<< endl;
int x;
cin >> x;
if (x == 1)
{
cout << "请输入插入对象"<< endl;
char *a;
string s1;
a = new char[20];
gets_s(a, 20);
s1 = a;
charu(s, s1);
delete[]a;
a = NULL;
}
if (x == 2)
{
shanchu(s);
}
if (x == 3)
{
cout << "请输入替换的目标区域,以及替换的内容"<< endl;
int t, m;
cin >> t >> m;
char*a;
a = new char[20];
gets_s(a, 20);
tihuan(t, m, s, a);
}
if (x == 4)
{
chazhao(s);
}
if (x == 5)
{
return 0;
}
system("pause");
return 0;
}
明日任务:继续复习前面知识,尝试做一个自己想的程序,继续学习链表。
- 我的学习记录33
- 我的学习记录
- 我的学习记录
- 我的学习记录
- 记录生活,记录学习----我的2016
- 开始我的学习记录
- 记录我的学习过程
- 我的OGRE学习记录
- 我的oracle学习记录
- 我的PHP学习记录。
- 我的Linux学习记录
- 记录我的学习历程
- 记录我的Android学习
- 记录我的学习过程
- [cocos2dx]我的学习记录
- 记录我的学习过程
- 我的学习记录整理
- 我的Golang学习记录
- Dynamic OCT 和 Dynamic ODT 详细说明
- G
- excel
- JavaScript中的文档碎片DocumentFragment
- 1. Two Sum
- 我的学习记录33
- shell脚本部分基础详解
- Throwable#initCause(Throwable) 方法
- ButterKnife
- 分析下面代码有什么问题?
- F
- 个人笔记——杂七杂八
- 关于VHDL的一些总结
- HDU2027 统计元音【入门】