短期班_C
tangobravo
此人不懒,但是也什么都没有写
展开
-
190104作业-删除一个数组中重复的元素
删除一个数组中重复的元素。例如 1 ,2, 2,2,3,3,3,4,4,5,5,5,6,6,6 -> 1,2,3,4,5,6 #include <stdio.h>#include <stdlib.h>#define MAX 100//首先考虑有序数组int Delete_Dup(int *R, int iLen){ int i = 1; int ...原创 2019-01-05 12:50:38 · 330 阅读 · 0 评论 -
190104作业-删除字符串中指定字符
删除字符串中指定的字符。 例如 “abcdaefaghiagkl“ 删除‘a’,以后: “bcdefghigkl”此算法仅需要一次遍历,只有O(n)的时间复杂度我原先的算法需要O(n^2)的时间复杂度#include <stdio.h>#include <stdlib.h>#define MAX 100void delete_char(){ cha...原创 2019-01-05 12:55:05 · 356 阅读 · 0 评论 -
190104作业-字符串空格替换为指定字符串
题目:将 字 符 串 中 的 空 格 替 换 成 “%020” , 例 如 “hello world how ”->”hello%020%020%020world%020%020%020how%020%020%020%020”遍历两次,第一次数出空格数,申请新的字符串,再次遍历进行替换#include <stdio.h>#include <stdlib.h>...原创 2019-01-05 12:58:05 · 347 阅读 · 0 评论 -
190104作业-将包含字符数字的字符串分开
将包含字符数字的字符串分开,使得分开后的字符串前一部分是数字后一部分是字母。例如“h1ell2o3” ->”123hello”/*不考虑可以使用额外空间的情况是很好完成,如何实现原地分离??值得思考。还可以考虑数字是无序的情况。*/#include <stdio.h>#include <stdlib.h>#include <string.h&...原创 2019-01-06 00:06:28 · 974 阅读 · 0 评论 -
190104作业-将字符串中的相邻的多余空格去掉
将 字 符 串 中 的 相 邻 的 多 余 空 格 去 掉 , 例 如 (空 格 用 下 划 线 表示): ”___hello____world___how_are_you__” ->”hello_world_how_are_you”可以考虑不使用额外空间,原地置换。#include <stdio.h>#include <stdlib.h>#defin...原创 2019-01-06 00:09:41 · 723 阅读 · 0 评论 -
190104作业-字符串实现大整数加法
大整数加法。 实现任意范围的两个整数的加法( 整数的范围用 int 型的变量无法表示,50位) #include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX 50//两个整数最多49位void Inverse(char *s)//翻转字符串{ char temp;...原创 2019-01-07 10:09:24 · 363 阅读 · 0 评论 -
从(0,0)到(m,n),每次走一步,只能向上或者向右走
从(0,0)到(m,n),每次走一步,只能向上或者向右走,有多少种路径走到(m,n)来自腾讯的面试题。 主要是要把递归的流程分析清楚,这个问题就是一个二叉树DFS类似的问题,判断稍微复杂,每步都只能往两个方向走,右或者上,截止条件是:0==m&&0==n输出存储的路径,并且将total计数加1。如果m<0||n<0返回否则分别走两条路...原创 2019-01-07 22:31:34 · 4003 阅读 · 1 评论