
作业社区
探索学习新天地,共享知识资源!
慕运维8597106 的学生作业:
#include using namespace std; template class SeqList { public: SeqList(int size); ~SeqList(); int addData(const T &data) { if(index >= size) { cout size == 0) { return -1; } for(i = 0; i < this->size; i++) { if(this->buf[i] != data) { this->buf[j] = this->buf[i]; j++; } } this->count = j; return i != j; } void show() { for(int i = 0; i < this->count; i++) { cout buf; } int main(int argc, const char *argv[]) { SeqList *list = new SeqList(3); list->addData("hello"); list->addData("world"); list->addData("test"); //list->addData("ttt"); list->show(); list->removeData("world"); list->show(); delete list; return 0; } 执行结果: linux@linux:~/learn/chapter17$ ./a.out 第0个元素:hello 第1个元素:world 第2个元素:test 删除world之后: 第0个元素:hello 第1个元素:test linux@linux:~/learn/chapter17$





浪潮君 的学生作业:
// 练习1 1、在用户主⽬录新建一个⽬录shell mkdir ~/shell 2、拷贝/etc/passwd⽂件到你的shell⽬录 cp /etc/passwd ~/shell/ 3、将shell⽬录备份成shell-bak cp -r ~/shell ~/shell-bak 4、对shell-bak进行压缩,压缩成shll-bak.tar.gz tar -czvf ~/shell-bak.tar.gz ~/shell-bak 5、复制压缩后的⽂件到你的共享⽬录 cp ~/shell-bak.tar.gz ~/Public/ 6、查看共享⽬录shell-bak.tar.gz的⼤⼩。 ls -l ls -l ~/Public/shell-bak.tar.gz // 练习2 #!/bin/zsh # 获取脚本名 file_name=$(basename "$0") # 获取全部参数 input="$*" # 计算单词数 word_count=$(echo "$input" | wc -w) # 输出信息 echo "file_name : $file_name" echo "word_count : $word_count" echo "return_value : $?" # 表示上一个命令的返回值 echo "string : $input" # 返回 0 表示成功 exit 0




