
作業(yè)社區(qū)
探索學(xué)習(xí)新天地,共享知識(shí)資源!
MyStudy_HYB 的學(xué)生作業(yè):
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 的學(xué)生作業(yè):
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 $?





浪潮君 的學(xué)生作業(yè):
#include #include class String { public: // 構(gòu)造函數(shù),接受一個(gè) C 風(fēng)格字符串,默認(rèn)值為 nullptr String(const char *str = nullptr) { if (str) { // 分配內(nèi)存并復(fù)制內(nèi)容(深拷貝) this->str = new char[strlen(str) + 1]; std::strcpy(this->str, str); } else { // 若為空字符串,分配一個(gè)只含 '\0' 的字符數(shù)組 this->str = new char[1]; this->str[0] = '\0'; } } // 拷貝構(gòu)造函數(shù),確??截悤r(shí)也進(jìn)行深拷貝 String(const String &other) { str = new char[strlen(other.str) + 1]; std::strcpy(str, other.str); } // 賦值運(yùn)算符重載,防止對(duì)象賦值出現(xiàn)淺拷貝問(wèn)題 String &operator=(const String &other) { if (this != &other) { // 先釋放原來(lái)的內(nèi)存 delete[] str; // 再深拷貝新內(nèi)容 str = new char[strlen(other.str) + 1]; std::strcpy(str, other.str); } return *this; } // 析構(gòu)函數(shù),釋放動(dòng)態(tài)分配的內(nèi)存 ~String() { delete[] str; } // 展示字符串的每個(gè)字符及其 ASCII 碼 void show() const { for (int i = 0; str[i] != '\0'; ++i) { std::cout





鵬程2013 的學(xué)生作業(yè):
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 : $*”





鵬程2013 的學(xué)生作業(yè):
練習(xí)1 顯示 /etc/passwd 第34行這一行的信息 head -n 34 /etc/passwd | tail -n 1 練習(xí)2 1.獲得root用戶在 /etc/passwd中以":"分割的1,3,4列的信息 cat /etc/passwd | grep root | cut -d: -f1,2,4 2.獲得linux用戶在 /etc/passwd中的行號(hào) cat /etc/passwd |grep linux -n | cut -d: -f1




