한줄에 변수두개를 같은값으로 초기화하려면 어떻게 해야하나요?
마호
2023.09.05
질문 제목 :
한줄에 변수두개를 같은값으로 초기화하려면 어떻게 해야하나요?
한줄에 변수두개를 같은값으로 초기화하려면 어떻게 해야하나요?
질문 내용 :
int comp, pla;
int max_win, max_los = 0;
int win, los = 0;
int yun_w, yun_l = 0;
int tot = 1;
float win_per = 0.0;
이렇게 변수선언을 했는데 자꾸 max_los 처럼 뒤에있는값이 초기화가 안된걸로 출력이 되네요....
int comp, pla;
int max_win= 0;
int max_los = 0;
int win, los = 0;
int yun_w= 0;
int yun_l = 0;
int tot = 1;
float win_per = 0.0;
이렇게 바꾸면 잘되구요 ㅜㅜ
한줄에 변수두개를 같은값으로 출력하려면 어떻게 해야하나요?
너무 기초적인 질문이라 부끄럽네요...
-
흰양말 2023-09-05
고맙습니다!!!! ㅠㅠㅠㅠ
-
영빈이 2023-09-05
int a,b =0;
은
int a;
int b = 0;
과 같습니다. -
백합 2023-09-05
답변감사합니다! int a, b =0 은 잘못된 건가요??
-
한말글 2023-09-05
int a=1, b=2, c=3;
int d,e,f;
d=e=f=0;
int g,h,i;
g=1,h=2,i=3;