728x90
#include <stdio.h>

int main() {

	int a = 9, b = 4;

	printf("%d %.1lf", a + b, (double)(a + b) / 2);
	
	return 0;

}

 

โ–ถ๋ฌธ์ œ: ๋‘ ์ •์ˆ˜ a, b๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋‘ ์ •์ˆ˜์˜ ํ•ฉ๊ณผ ํ‰๊ท ์„ ๊ตฌํ•ด ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด ๋ณด์„ธ์š”.

#include <stdio.h>

int main() {
    int a, b;

    scanf("%d %d",&a,&b);
    printf("%d %.1lf",a+b,(double)(a+b)/2);
    return 0;
}

โ–ถ๋ฌธ์ œ: ์„ธ ๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ ํ•ฉ๊ณ„์™€ ํ‰๊ท ์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”.

(๋‹จ, ํ‰๊ท ์€ ์†Œ์ˆ˜ ์ดํ•˜๋ฅผ ๋ฒ„๋ฆฝ๋‹ˆ๋‹ค.)

#include <stdio.h>

int main() {
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    printf("%d\n",a+b+c);
    printf("%d",(a+b+c)/3);
    return 0;
}

โ–ถ๋ฌธ์ œ: ์„ธ ๊ฐœ์˜ ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์„ธ ์ •์ˆ˜์˜ ํ•ฉ๊ณผ ํ‰๊ท ์„ ๊ตฌํ•˜๊ณ , ํ•ฉ์—์„œ ํ‰๊ท ์„ ๋บ€ ๊ฐ’์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด ๋ณด์„ธ์š”.

#include <stdio.h>

int main() {
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    printf("%d\n",a+b+c);
    printf("%d\n",(a+b+c)/3);
    printf("%d",(a+b+c)-(a+b+c)/3);
    return 0;
}

+ Recent posts