![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码
文章平均质量分 79
波光粼粼
底层搬砖
展开
-
字符串最后一个单词的长度
第一道循环的题 思路是将字符串读入,然后逆序排列,将字符串流打散,保留第一个单词,再逆序就是原字符串的最后一个单词。 实现的思路有些繁琐,代码如下: #include #include #include #include using namespace std; void main(){ string str; getline(cin,str);//读入字符串 revers原创 2016-07-27 11:53:33 · 256 阅读 · 0 评论 -
合唱队
需要寻找的是最大的合唱队队形,不一定从头开始 也不一定留下最后一个人。更不是从最高的那个人向左右。 这是一个动态规划的问题。 考虑将每个人身上带两个属性,一个是从左过来的最大的递增数列长度,一个是从右过来的最大的递增数列长度。 两者和最大的那个自然就是合唱队队形中应该保留的身高最高的那个人。 #include using namespace std; int原创 2016-07-27 16:45:06 · 276 阅读 · 0 评论 -
图片排序
简单的冒泡排序 抽时间写下其他排序方法的 view plaincopy to clipboardprint? #include #include #include using namespace std; void main(){ string str; getline(cin, str); i原创 2016-07-27 18:25:10 · 301 阅读 · 0 评论 -
挑7
这个比较简单 #include //#include using namespace std; void main(){ int n; cin >> n; int j = 0; for (int i = 1; i < n+1; i++){ if (0 == (i % 7)){ j++; } else if (7 == (i % 10)){ j++; }原创 2016-07-28 11:17:06 · 208 阅读 · 0 评论 -
名字的美丽度
做了几遍 不是格式错误就是答案错误 = = 是输入的格式不对。最后终于成功了。 下面的程序在电脑上可以正常运行。 总结一下:既然用到了algorithm的sort函数 就不需要用冒泡排序了 直接进行sort即可。 利用ctype.h的tolower函数将大写字母转化为小写字母。 然后利用小写字母和数字之间的ASCII码关系进行数列序数的变换。 #includ原创 2016-07-28 10:27:40 · 279 阅读 · 0 评论 -
字符串加解密
#include #include #include using namespace std; #define MAX 100 void Encrypt(char aucPassword[], char aucResult[]); int unEncrypt(char result[], char password[]); /*void main(){ co原创 2016-07-28 15:59:15 · 309 阅读 · 0 评论 -
蛇形矩阵
是个数学问题 将斜三角矩阵的每个点设为i行j列。 行和列数的和小于等于输入数字,且数学关系为num= (i + j + 1)*(i + j + 2) / 2 - i #include using namespace std; void main(){ int i, j, n, num; cin >> n; for (i = 0; i for (j = 0; j n原创 2016-07-28 16:48:28 · 324 阅读 · 0 评论