728x90
- ๊ณต๋ฐฑ์ ์ฌ์ด์ ๋๊ณ ๋ ๊ฐ์ ์๋ฅผ ์ ๋ ฅ๋ฐ๊ณ ์ถ๋ค๋ฉด ๋ ๊ฐ์ %d ๋ณ์ํฌ๋งท์ ์ด์ฉํด ์ ๋ ฅ๋ฐ์ ์ ์๋ค.
- %d%d๋ก ์ ๋ ฅ๋ฐ์๋ ์๊ด์๋ค.
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d", a, b);
return 0;
}
- ํ์ง๋ง ๋ฌธ์๋ฅผ ๊ณต๋ฐฑ์ ์ฌ์ด์ ๋๊ณ ์ ๋ ฅ๋ฐ๋ ๊ฒฝ์ฐ์๋ ์ฃผ์
#include <stdio.h>
int main() {
char a, b;
scanf("%c", &a);
scanf(" %c", &b);
printf("%c %c", a, b);
return 0;
}
int main() {
char a, b;
scanf("%c %c", &a, &b);
printf("%c %c", a, b);
return 0;
}
- ๋ฌธ์์ด์ ์ ๋ ฅ๋ฐ์ ๋๋ ๋ฐฐ์ด์ ์ด์ฉ
char a[15];
%s
#include <stdio.h>
int main() {
char a[10], b[10];
scanf("%s %s", a, b);
printf("%s\n", a);
printf("%s", b);
return 0;
}
โถ๋ฌธ์ : ๋ ์ ์ ์ ๋ฅผ ์ ๋ ฅ๋ฐ์ ํ, ์ ๋ฅผ ๊ณฑํ ๊ฐ์ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํด ๋ณด์ธ์.
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d",&a,&b);
printf("%d",a*b);
return 0;
}
โถ๋ฌธ์ : ์ ์ a, b๋ฅผ ์ ๋ ฅ๋ฐ๊ณ , a์ b๋ฅผ ๋ํด์ค ๊ฐ์ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํด ๋ณด์ธ์.
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
โถ๋ฌธ์ : ์ ์ a, b๋ฅผ ์ ๋ ฅ๋ฐ๊ณ , a์ b์ ์์น๋ฅผ ๊ตํํ ํ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์ธ์.
#include <stdio.h>
int main() {
int a, b;
int temp;
scanf("%d %d",&a,&b);
temp = a;
a = b;
b = temp;
printf("%d %d",a,b);
return 0;
}
โถ๋ฌธ์ : ์ ์ a์ b๋ฅผ ์ ๋ ฅ๋ฐ๊ณ , a, b, a์ b์ ํฉ์ ์ฐจ๋ก๋๋ก ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํด ๋ณด์ธ์.
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d %d",a,b,a+b);
return 0;
}