U E D R , A S I H C RSS

PP Project/20041001FM

PPProject ์ฒซ ๋ฒˆ์งธ ๋งŒ๋‚จ์˜ ๊ฒฐ๊ณผ๋ฌผ


1. ๋ฌธ์ œ

์ปฌ๋Ÿผ 2. B๋ฒˆ ๋ฌธ์ œ
n๊ฐœ์˜ ์›์†Œ๋ฅผ ๊ฐ€์ง€๋Š” 1์ฐจ์› ๋ฒกํ„ฐ๋ฅผ i๋งŒํผ ์™ผ์ชฝ์œผ๋กœ ํšŒ์ „์‹œ์ผœ๋ผ.

1.1. Leonardong


~cpp 
#include <iostream>
#include <string>
using namespace std;

void roll( string str, int i );

void main()
{
	string str = "abcde";
	int i = 3;
	roll(str, i);
}

void roll( string str, int i )
{
	cout << str << endl;
	
	int n = str.length();
	char temp;
	
	for ( int tag = 0 ; tag < n ; tag++ ){
		temp = str[tag];
		str[tag] = str[i-1];
		str[i-1] = temp;
		i = i < n ? i+1 : i;
	}
	cout << str << endl;
}

1.2. ์žฌ์„  ํšŒ์˜


~cpp 
#include<iostream.h>
#include<cstring>

void roll(int i);

char * string="ABCDEFGHIJKLMNOPQRSTUV";
const int SIZE = strlen(string);


void main()
{	
	roll(4);
}

void roll(int i)
{
	char* buffer1 = new char[i];
	strncpy(buffer1, string, i);
	buffer1[i] = 0;
	char *buffer2 = new char[SIZE-i];
	strcpy(buffer2,string+i);
	cout<<strcat(buffer2,buffer1)<<endl;	
}

 

2. ํ›„๊ธฐ

์žฌ์„  :
์ฒซ ๋ชจ์ž„์ด๋ผ ์Šคํ„ฐ๋”” ๋ฐฉ์‹์„ ์ •ํ•˜๋Š”๋ฐ ์‹œ๊ฐ„์ด ์˜ค๋ž˜ ๊ฑธ๋ ธ๋‹ค. ํšŒ์˜์ด์™€ PairProgramming ์„ ํ•˜๋Š”๋ฐ ๋„ˆ๋ฌด ์—ฌ์œ ๊ฐ€ ์—†์—ˆ๋‹ค.
Leonardong:
์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์•Œ์•„๋„ ์ฝ”๋“œ๋กœ ๋ฐ”๋กœ ํ’€์–ด์“ฐ๊ธฐ๊ฐ€ ์•ˆ ๋œ๋‹ค. ๊ทธ๋Ÿด ๋•Œ๋Š” ๊ฐ€์งœ ์ฝ”๋“œ(psuedo code)๋ฅผ ์ ์–ด๋ณด๋Š” ๊ฒƒ์ด ๋„์›€์ด ๋œ๋‹ค.


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:59
Processing time 0.0076 sec