Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

새싹교실/2012/열반/120521: Difference between revisions

From ZeroWiki
imported>joojis
No edit summary
imported>joojis
No edit summary
Line 6: Line 6:
  void swap(int *a, int *b){
  void swap(int *a, int *b){
  int temp;
  int temp;
  temp=*a;
  temp=*a;
  *a=*b;
  *a=*b;
  *b=temp;
  *b=temp;
  }
  }
  //분석해보세요
  //분석해보세요
  void swap(int *a, int *b){
  void swap(int *a, int *b){
  a^=b^=a^=b;
  if((*a)!=(*b)){
*a^=*b^=*a^=*b;
}
}
int main()
{
int x=5, y=10;
printf("%d %d\n", x, y);
swap(&x, &y);
printf("%d %d\n", x, y);
return 0;
  }
  }
== 문자열 출력 ==
== 문자열 출력 ==

Revision as of 08:19, 22 May 2012

출석

*권우성

수업 내용

스왑

void swap(int *a, int *b){
	int temp;

	temp=*a;
	*a=*b;
	*b=temp;
}

//분석해보세요
void swap(int *a, int *b){
	if((*a)!=(*b)){
		*a^=*b^=*a^=*b;
	}
}

int main()
{
	int x=5, y=10;

	printf("%d %d\n", x, y);

	swap(&x, &y);

	printf("%d %d\n", x, y);

	return 0;
}

문자열 출력

void printstring(char *ptr){
	while(*ptr){
		putc(*ptr, stdout);
		ptr++;
	}
}
void main(){
	prints("abcd");
}