/*
#include <stdio.h>
int main()
{
int a=10;
int* pa = &a;
printf("a : %d\n",a);
printf("&a : %d\n",&a);
printf("pa : %d\n",pa);
printf("*pa : %d\n",*pa);
*pa=50;
printf("*pa : %d\n",*pa); // 간접 참조 연산자
printf("a : %d\n",a); // 직접 참조 연산자
return 0;
}
#include <stdio.h>
//void f(int* pa)
//{
// *pa=50;
//}
void f(int* pa, int n)
{
// *pa -> a[0]
// *(pa+1) -> a[1]
// ...
// *(pa+i) -> a[i]
for(int i=0;i<n;i++)
printf("%d ",*(pa+i));
}
int main()
{
int a[1000]={};
int n=10;
//f(&a[0]); (ok)
//f(a); (ok)
for(int i=0;i<n;i++) a[i]=i;
f(a,n); // 0번째 원소의 주소 , 길이 전달
// char str[50]="hello";
//
// scanf("%s",str); // str = &str[0]
//
// int a=10;
// printf("a : %d\n",a);
// f(&a);
// printf("a : %d\n",a);
return 0;
}
#include <stdio.h>
void myswap(int* pa,int* pb)
{
int n;
n=*pb;
if(*pa>*pb){
pb=pa;
*pa=n;
}
}
main()
{
int a, b;
scanf("%d%d", &a, &b);
myswap(&a, &b);
printf("%d %d", a, b);
}
*/
/*
#include <stdio.h>
void f(char* str, int a,int b)
{
for(int i=a-1;i<b;i++){
printf("%c",str[i]);
}
}
int main()
{
char str[101]={};
int a,b;
gets(str);
scanf("%d %d",&a,&b);
f(str,a,b);
}
#include <stdio.h>
char* mysubstr(char *str,int start,int count)
{
str[start+count]=0;
return &str[start];
}
int main()
{
int s,c;
char str[101];
gets(str);
scanf("%d %d",&s,&c);
printf("%s",mysubstr(str,s,c));
}
#include <stdio.h>
#include <windows.h>
#include <Windows.h>
void textcolor(int colorNum) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorNum);
}
void gotoxy(int x, int y)
{
COORD Pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
int main()
{
for(int i=0;i<16;i++){
//gotoxy(5,5); // 출력할 위치 지정하기
textcolor(i); // 0 ~15까지 글자 색상 지정하기
gotoxy(i,i);
printf("#");
//printf("안녕 민우야");
Sleep(1); // 1초 1000 , 0.5초 500
// system("cls"); // 다 지우기
// Sleep(1000);
}
return 0;
}
rand() : 0 ~ 32767
rand()%10 : 0 ~9
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <Windows.h>
void textcolor(int colorNum) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorNum);
}
void gotoxy(int x, int y)
{
COORD Pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
int main()
{
char str[101];
int n,i;
gets(str);
scanf("%d",&n);
srand(time(NULL));
for(i=3;i<n+3;i++){
int a = rand()%25;
int b = rand()%10;
gotoxy(a,b);
textcolor(i%16);
printf("%s",str);
Sleep(100);
}
}
*/