ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฌธ์ : ๋ ๊ฐ์ ๋ณต์์๋ฅผ ์ ๋ ฅ ๋ฐ๊ณ , ๋ ๋ณต์์๋ฅผ ๋ํ ๊ฒฐ๊ณผ๊ฐ์ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
์กฐ๊ฑด: ๊ตฌ์กฐ์ฒด ์ ์, add ํจ์ ์ ์, main ํจ์์์ ์ ๋ ฅ ๋ฐ ์ถ๋ ฅ
์ฝ๋:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct complex { //๋ณต์์ ๊ตฌ์กฐ์ฒด ์ ์
double sil, huh; //๋ณต์์์ ์ค์๋ถ์ ํ์๋ถ
};
struct complex add(struct complex a, struct complex b); //ํจ์ ์ํ ์ ์ธ, ๊ตฌ์กฐ์ฒด ํจ์๋ก ์ค์ ํ๊ธฐ ์ฃผ์**
int main() {
struct complex a, b, c;
scanf("%lf %lf", &a.sil, &a.huh);
scanf("%lf %lf", &b.sil, &b.huh);
c = add(a, b); //add ํจ์๋ฅผ int๋ก ์ ์ธํ๋ฉด ์ด๋ถ๋ถ์์ ์ค๋ฅ๊ฐ ๋จ
printf("%.1f + %.1fi", c.sil, c.huh);
return 0;
}
struct complex add(struct complex a, struct complex b) {
struct complex c;
c.sil = a.sil + b.sil;
c.huh = a.huh + b.huh;
return c;
}
๋ฐ์ํ
'Programming > c' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- ํ๋ก๊ทธ๋๋จธ์ค
- HyperCLOVA
- ์ฝํ ์ค๋น
- AI์ปจํผ๋ฐ์ค
- ๊ธฐ์ ์ปจํผ๋ฐ์ค
- ๋ ผ๋ฌธ์ฝ๊ธฐ
- gan
- SQL
- AIRUSH
- DALLE
- WGAN
- ๊ตฌ๊ธ์ฝ๋ฉ
- MYSQL
- ํ์ด์ฌ์ฝํ
- SKTECHSUMMIT
- CLOVAX
- C์ธ์ด
- dreambooth
- ํ์ด์ฌ
- StableDiffusion
- ๋๋ฆผ๋ถ์ค
- ํ ํฌ์๋ฐ
- AIRUSH2023
- ์ฝ๋ฉ์๋ฌ
- ์คํ ์ด๋ธ๋ํจ์
- ์ฝ๋ฉ๊ณต๋ถ
- ์ฝํ
- lgaimers
- ๋ ผ๋ฌธ๋ฆฌ๋ทฐ
- Aimers
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
๊ธ ๋ณด๊ดํจ