
作业社区
探索学习新天地,共享知识资源!
MyStudy_HYB 的学生作业:
namespace A_Space { int calc(int a, int b) { return a + b; } } // namespace A_Space namespace B_Space { int calc(int a, int b) { return a - b; } } // namespace B_Space #ifndef _SPACE_HEAD_H #define _SPACE_HEAD_H namespace A_Space { extern int calc(int a, int b); } namespace B_Space { extern int calc(int a, int b); } #endif #include #include "space.h" using namespace std; int main() { int a= 30, b= 20; cout





鹏程2013 的学生作业:
practice 1 #! /bin/bash echo "please input year month day" read year month day echo “year−year-year−month-$day” prcatice 2 #! /bin/bash echo "please input two num" read var1 var2 plus=expr $var1 + $var2 echo “echo $var1 + $var2 = $plus” plus=expr $var1 - $var2 echo “echo $var1 - $var2 = $plus” plus=expr $var1 \* $var2 echo “echo $var1 * $var2 = $plus” plus=expr $var1 \% $var2 echo “echo $var1 % $var2 = $plus” practice 3 #! /bin/bash echo "please input one num" read var1 test $var1 -ge 0 && test $var1 -lt 60 echo $?





浪潮君 的学生作业:
#include #include class String { public: // 构造函数,接受一个 C 风格字符串,默认值为 nullptr String(const char *str = nullptr) { if (str) { // 分配内存并复制内容(深拷贝) this->str = new char[strlen(str) + 1]; std::strcpy(this->str, str); } else { // 若为空字符串,分配一个只含 '\0' 的字符数组 this->str = new char[1]; this->str[0] = '\0'; } } // 拷贝构造函数,确保拷贝时也进行深拷贝 String(const String &other) { str = new char[strlen(other.str) + 1]; std::strcpy(str, other.str); } // 赋值运算符重载,防止对象赋值出现浅拷贝问题 String &operator=(const String &other) { if (this != &other) { // 先释放原来的内存 delete[] str; // 再深拷贝新内容 str = new char[strlen(other.str) + 1]; std::strcpy(str, other.str); } return *this; } // 析构函数,释放动态分配的内存 ~String() { delete[] str; } // 展示字符串的每个字符及其 ASCII 码 void show() const { for (int i = 0; str[i] != '\0'; ++i) { std::cout





鹏程2013 的学生作业:
home1.sh #! /bin/bash mkdir ~/shell cp /etc/passwd ~/shell/passwd cd ~ cp -r shell shell-back tar -zcvPf shell-back.tar.gz ~/shell-back cp shell-back.tar.gz /usr/share/shell-back.tar.gz ls -lh /usr/share/shell-back.tar.gz home2.sh #! /bin/bash echo "file_name : $0" echo "word_count : $#" echo "return value : $?" echo “string : $*”




