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.0158 sec