U E D R , A S I H C RSS

문자반대출력/허아영

*(pCh+lenstr-i-1) = tempi;
*(pCh+lenstr-i) = tempi; , , .
;;

char 함 . .
. .
~!

  • ver2 .
    ,
    .
    ... +_+
  • ver.2 !
    .
    펙토 .
    : 한 . ver.3 .
    choiceNum , 한, 화 하 .

ver.1


~cpp 
/*파     */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char strchange(char ch[50], int lenstr);

void main()
{
	char ch[50], *pCh;
	int lenstr;
	FILE *fp1, *fp2;
	pCh = ch;
	fp1 = fopen("source.txt", "r");
	fgets(ch, 50, fp1); //파  
	fclose(fp1);
	printf("Before string = %s \n", ch);
	lenstr = strlen(ch);	
	*pCh = strchange(pCh, lenstr);
	fp2 = fopen("result.txt", "w");
	printf("After string = %s \n", ch);
	fputs(ch, fp2);
	fclose(fp2);
	
}

char strchange(char *pCh, int lenstr)
{
	int i;
	char temp[50];
	for(i = 0; i <= lenstr; i++)
	{
		temp[i] = *(pCh+i);
	}
	for(i = 0; i <=lenstr; i++)
	{
		*(pCh+lenstr-i-1) = temp[i];
	}
	return *pCh;	
}

ver.2

~cpp /*파      ver.2*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char strchange(char ch[50], int lenstr, int choiceNum);

void main()
{
	char ch[50], *pCh;
	int lenstr, choiceNum, i = 0;	
	FILE *fp1, *fp2;
	pCh = ch;
	fp1 = fopen("source.txt", "r");
	fp2 = fopen("result.txt", "w");
	fgets(ch, 50, fp1); //파  
	lenstr = strlen(ch);
	if('A'<= ch[i] && ch[i] <='z')
	{
		choiceNum = 0; // 
	}else
	{
		choiceNum = 1; // 한??
	}
	*pCh = strchange(pCh, lenstr, choiceNum);
	fputs(ch, fp2);
	fclose(fp1);
	fclose(fp2);
}

char strchange(char *pCh, int lenstr, int choiceNum)
{
	int i;
	char temp[50];
	switch(choiceNum)
	{
	case 0:
		for(i = 0; i <= lenstr; i++)
		{
			*(temp+i) = *(pCh+i);
		}
		for(i = 0; i <= lenstr; i++)
		{
			*(pCh+lenstr-i-1) = *(temp+i);
		}
		break;
		
	case 1:
		for(i = 0; i < lenstr; i++)
		{
			*(temp+i) = *(pCh+i);
		}
		for(i = 0; i < lenstr; i+=2)
		{
			*(pCh+lenstr-i-2) = *(temp + i);
			*(pCh+lenstr-i-1) = *(temp+i+1);
		}
		break;
	}	
	return *pCh;	
}

C++

~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();
};

한테 할


. 置麗零 .... ..ㅠ.ㅠ --
. 한 (1트) 2. . 한 2트 확 . -
2 -_- 판 1 2 ? -태훈 zyint
ascii code MSB ( most significant bit) 1 .. 2 .. -
, , 하 . MSB . MSB . --
MSB . 10001000 1 MSB. 0 LSB (Least Significant Bit). BigEndian Machine , , 키텍 MSB, LSB , LittleEndian ( ) 키텍 LSB MSB . 키텍 ascii . ascii 0~127 8트 2 MSB 0 . 1 , MSB 1 (, 2) .




Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:30
Processing time 0.0165 sec