{{{~cpp //8_1 #include using namespace std; void Print(char *in,int i=0); int main() { char *ex="캬캬캬 출력한다.~"; Print(ex); Print(ex,0); Print(ex,10); char *ex2="2번재 출력"; Print(ex2,100); return 0; } void Print(char *in,int i) { static int count=0; if(i==0) cout<0) { cout< using namespace std; struct CandyBar { char *Brand; double Weight; int Calory; }; void StructFunction(CandyBar &in, char *brand="Millennium Munch", double weight=2.85,int calory=350); int main() { CandyBar ex1,ex2; StructFunction(ex1,"kakakaka",4.67,400); StructFunction(ex2); return 0; } void StructFunction(CandyBar &in,char *brand,double weight, int calory) { in.Brand = brand; in.Calory = calory; in.Weight = weight; cout< using namespace std; #include struct stringy { char *str; int ct; }; void set(stringy &in, char copied[]); void show(const stringy in, int iteration=1); void show(const char in[], int iteration=1); int main() { stringy beany; char testing[] = "Reality isn't what it used to be."; set(beany,testing); show(beany); show(beany,2); testing[0] = 'D'; testing[1] = 'u'; show(testing); show(testing,3); show("Done!"); return 0; } void set(stringy &in, char copied[]) { int ct=strlen(copied); in.str = new char [ct-3]; ct=strlen(in.str); strncpy(in.str,copied,ct); } void show(const stringy in, int iteration) { while(iteration>0) { cout<0) { cout< #include using namespace std; int setgolf(golf &g) { char name[30]; int handicap; cout<<"Input the name: "; cin >>name; strcpy(g.fullname,name); cout<<"Input the handicap : "; cin>>handicap; g.handicap = handicap; if(name==NULL) return 0; else return 1; } void setgolf(golf &g, const char *name, int hc) { strcpy(g.fullname,name); g.handicap=hc; } void handicap(golf &g, int hc) { g.handicap=hc; } void showgolf(const golf &g) { cout< using namespace std; template Any max(Any in[5]); void main() { int ex[5]; double ex2[5]; for(int i=0;i<5;i++) { ex[i]=i*10; ex2[i]=(0.1)*i; } int re1 = max(ex); double re2 = max(ex2); cout< Any max(Any in[5]) { Any max = in[0]; for(int i=0;i<5;i++) { if(in[i]>=max) max=in[i]; } return max; } 6번 문제 #include using namespace std; #include template template <> char* max(char* in[], int i); template Any max(Any in[], int i); void main() { int ex[5]; double ex2[5]; for(int i=0;i<5;i++) { ex[i]=i*10; ex2[i]=(0.1)*i; } char *input[4]; input[0]="asddff\n"; input[1]="asddfffasdfadfadfdf4$$$$$$$f\n"; input[2]="asd\n"; input[3]="aasdfadsf3\n"; char *re; int re1 = max(ex,5); double re2 = max(ex2,5); re = max(input,4); cout< Any max(Any in[], int i) { Any max = in[0]; for(int j=0;j=max) max=in[j]; } return max; } char* max(char* in[], int i) { int count=0; int maxCount=0; char *max = in[0]; for(int j=0;jstrlen(max)) max=in[j]; } return max; } }}}