U E D R , A S I H C RSS

c++스터디_2005여름/실습코드

No older revisions available

No older revisions available



C++스터디_2005여름 참가자가 스터디한 날 공부 한 내용을 올리는 공간입니다.

2005. 8. 7.

허아영

~cpp 
//cpp1.cpp
#include <iostream.h>
#include <string.h>
#include "cpp.h"

void main()
{
	Mystring mystr;
	mystr.input();
	mystr.str_reverse();
	mystr.output();
}
~cpp 
//cpp2.cpp
#include <iostream.h>
#include "cpp.h"
#include <string.h>

void Mystring::str_reverse()
{
	str_len = strlen(ch);
	int i = 0;
	while(ch[i])// 간단히 영어만 된다.
	{
		str_temp[str_len-i-1] = ch[i];
		++i;
	}
}

void Mystring::input()
{
	cin>>ch;
}

void Mystring::output()
{
	int i = 0;
	while(str_temp[i] > 0)
	{
		cout<<str_temp[i];
		++i;
	}
	cout<<"\n";
}
~cpp 
//cpp.h
class Mystring
{
private :
	char ch[50];
	int str_len;
	char str_temp[50];

public :
	void str_reverse();
	void input();
	void output();
};

이규완

~cpp 

남도연

~cpp 
--------<sasa.h>-------------
class Mirror{
private:

	char munja[14];

public:
	void reverse();
	void input();
};
------<sasa2.cpp>----------
~cpp 
#include <math.h>
#include <iostream.h>
#include "sasa.h"
#include <string.h>
#include <stdlib.h>


void Mirror::input(){
	cin.getline(munja, 14, '\n');
}

void Mirror::reverse(){
		int  i;
		char space;
	for (i=0;i<floor(strlen(munja)/2);i++){
		space=munja[strlen(munja)-1-i];
		munja[strlen(munja)-1-i]=munja[i];
		munja[i]=space;
	}
	cout<<munja<<endl;
	
}
-------<sasa3.cpp>--------
~cpp 
#include "sasa.h"


void main(){
	Mirror count;
	count.input();
	count.reverse();
}


정수민

~cpp 
//main.cpp
#include "string.h"
 
void main()
{
 
Change str;
 str.input();
 str.revers();
 
}


~cpp 
//definition.cpp
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#include "string.h"
 
int
 i
 ;
 
 
void Change::input(){
 cout <<"입력 : ";
 cin.getline(moon_ja,50,'\n');
}
 
void Change::revers(){
 
 i = strlen(moon_ja)-1;
 
 while (1) {
  if (i<0) {break;}
  printf("%c",moon_ja[i]);
  i--;
 }
 printf("\n");
}


~cpp 
//string.h
class Change {
private:
 char
  moon_ja[50]
  ;
 
public:
 void revers();
 void input();
};



<05.8.11>


정수민

~cpp 
//main.cpp
#include "string.h"

void main()
{

Find 
	str
	;

str.input();
str.find();
str.reinput_and_find();
str.change("fighting zeropage!!");
str.add();
str.repetition();

}


~cpp 
//definition.cpp
#include <stdio.h>
#include <iostream>
using namespace std;
#include "string.h"

int
	i = 0
	;

void Find::input() {
	cout <<"문자열 입력 : ";
	cin.getline(moon_ja,50,'\n');
	cout <<"찾을 문자 입력 : ";
	cin.get(find_moon_ja);
}

void Find::find() {
	while (1) {
		if (find_moon_ja == moon_ja[i]) {
			break;
		}
		i++;
		if (moon_ja[i] == 0) {
			cout << find_moon_ja << "문자를 찾을 수가 없습니다." <<endl;
		}
	}
	if (moon_ja[i] != 0) {
		cout << i+1 << "번째 " << find_moon_ja << "문자가 있습니다." <<endl;
	}
}

void Find::reinput_and_find() {
	cin.get();
	while (1) {
		cout <<"문자열 입력 ('0'을 입력하면 정지) : ";
		cin.getline(moon_ja,50,'\n');
		if (moon_ja[0] == '0') {
			break;
		}
		while (1) {
			if (find_moon_ja == moon_ja[i]) {
				break;
			}
			i++;
			if (moon_ja[i] == 0) {
				cout << find_moon_ja << "문자를 찾을 수가 없습니다." <<endl;
				break;
			}
		}
		if (moon_ja[i] != 0) {
			cout << i+1 << "번째 " << find_moon_ja << "문자가 있습니다." <<endl;
		}
	}
}

void Find::change(char *a) {
	i=0;
	while (1) {
		moon_ja[i] = a[i];
		if (a[i]==0){
			break;
		}
		i++;
	}
	cout << moon_ja <<endl;
}

void Find::add() {
	int
		j
		;

	cout <<"추가할 문자 : ";
	cin.get();
	cin.getline(add_moon_ja,50,'\n');

	i=0;

	while (1) {
		if (moon_ja[i]==0){
			break;
		}
		i++;
	}

	j = i;

	while (1) {
		if (add_moon_ja[i]==0){
			break;
		}
		moon_ja[i] = add_moon_ja[i-j];
		i++;
	}
	cout << moon_ja <<endl;
}

void Find::repetition() {
	int 
		j
		;
	cout << "반복횟수 입력 : ";
	cin >> j;
	for (i=0;i<j;i++) {
		cout << moon_ja <<endl;
	}
}


~cpp 
//string.h
class Find { 
private: 
 char 
  moon_ja[50] 
  ,
  find_moon_ja
  ,
  add_moon_ja[50]
  ; 
  
public: 
	void find(); 
	void input();
	void reinput_and_find();
	void change(char *a);
	void add();
	void repetition();
}; 

study C++/ 한유선
study C++/남도연

- 덧붙여 주세요.



Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:37
Processing time 0.0209 sec