
作业社区
探索学习新天地,共享知识资源!
MyStudy_HYB 的学生作业:
my_strcpy函数 void my_strcpy(char* dest, const char* src) { int i = 0, j = 0; // 计算字符串src的长度,包含'\0' while (src[i++]); for (j = 0; j < i; j++) { dest[j] = src[j]; } return; } my_strcat函数 void my_strcat(char* dest, const char* src) { int i = 0, j = 0, k = 0; char* p = dest; // 计算dest有效字符串的长度 while (*p) { p++; } i = p - dest; // 计算src字符串长度包含第一个'\0' while (src[k++]); // 字符串dest追加src字符串 for (j = 0; j < k; j++) { dest[i + j] = src[j]; } return; } cpca头文件 #ifndef _CACP_HEAD_H #define _CACP_HEAD_H #ifdef __cplusplus extern "C" { #endif extern void my_strcat(char* dest, const char* src); extern void my_strcpy(char* dest, const char* src); #ifdef __cplusplus } #endif #endif main函数 #include #include "cpca.h" using namespace std; int main() { char a[100] = "hello,"; const char* b = "world"; char c[11] = "abcde"; cout





MyStudy_HYB 的学生作业:
#include using namespace std; class Time { private: unsigned int m_hour; unsigned int m_minute; unsigned int m_second; public: void setHour(unsigned int hour); void setMinute(unsigned int minute); void setSecond(unsigned int second); int getHour(void); int getMinute(void); int getSecond(void); }; void Time::setHour(unsigned int hour) { this->m_hour = hour; } void Time::setMinute(unsigned int minute) { this->m_minute = minute; } void Time::setSecond(unsigned int second) { this->m_second = second; } int Time::getHour(void) { return this->m_hour; } int Time::getMinute(void) { return this->m_minute; } int Time::getSecond(void) { return this->m_second; } int main() { int hour, minute, second; cin >> hour >> minute >> second; Time* pt = new Time; pt->setHour(hour); pt->setMinute(minute); pt->setSecond(second); cout




