๐Certificate/Engineer Information Processing
[์ ๋ณด์ฒ๋ฆฌ๊ธฐ์ฌ] ์ค๊ธฐ ํ๋ก๊ทธ๋๋ฐ์ธ์ด 3๋ฌธ์ (20)
Sun A
2024. 10. 3. 16:45
1๏ธโฃ [JAVA]
2023.1ํ
์๋ ์๋ฐ ์ฝ๋์์ ์ถ๋ ฅ๋๋ ๊ฐ์ ์์ฑํ์์ค. (๋ณต์ต)
class Static{
public int a = 20;
static int b = 0;
}
public class Test{
public static void main(String[] args) {
int a = 10;
Static.b = a;
Static st = new Static();
System.out.println(Static.b++);
System.out.println(st.b);
System.out.println(a);
System.out.print(st.a);
}
}
10
11
10
20
a์ 10 ์ ์ธ
Statc.b = a;
Static ํด๋์ค์ b๋ฅผ 10 ์ผ๋ก ๋ณ๊ฒฝ
st๋ฅผ Static ํด๋์ค๋ก ์ ์ธ
Static.b++ = 10
b++์ 1์ด ์ถ๊ฐ๋ ์ํ์ด์ง๋ง ๋ฐ๋ก 1์ด ์ถ๊ฐ๋ ์ฑ๋ก ์ถ๋ ฅ๋์ง ์์ ๋ค์ b ๋ถํฐ 11
(๋ง์ฝ, ++b ์ถ๋ ฅ์ด์๋ค๋ฉด 11๋ก ์ถ๋ ฅ๋์์ ๊ฒ)
st.b = 11 ์์์ 1์ด ์ถ๊ฐ๋ ์ํ์ b ์ถ๋ ฅ
a = 10
st.a = 20
2๏ธโฃ [JAVA]
2022.2
๋ค์ ์๋ฐ ์ฝ๋์ ์๋ง๋ ์ถ๋ ฅ๊ฐ์ ์์ฑํ์์ค.
public static void main(String args[]){
int i = 3; int k = 1;
switch(i) {
case 1: k += 1;
case 2: k++;
case 3: k = 0;
case 4: k += 3;
case 5: k -= 10;
default: k--;
}
System.out.print(k);
}
-8
i๊ฐ์ด 3์ด๊ธฐ ๋๋ฌธ์ case 3๋ถํฐ ๊ณ์ฐํ๋ค.
0
0 + 3
3 - 10
-7 -1
-8
3๏ธโฃ [C์ธ์ด]
2023.1ํ
๋ค์ ์ฝ๋์์ ๊ดํธ์์ ์๋ง๋ ๊ฐ์ ๋ณ์๋ช ์ผ๋ก ์์ฑํ์์ค.
#include
void swap(int *a, int idx1, int idx2) {
int t= a[idx1];
a[idx1] = a[idx2];
a[( โ )] = t;
}
void Usort(int *a, int len) {
for(int i = 0; i < len - 1; i++)
for(int j = 0; j < len - 1 - i; j++)
if(a[j] > a[j+1])
swap(a,j,j+1);
}
void main(){
int a[] = {85, 75, 50, 100, 95};
int nx = 5;
Usort(a, ( โก ));
}
โ idx2
โก nx
๋ฒ๋ธ์ ๋ ฌ ๋ฐฉ์์ผ๋ก ๊ฐ๊น์ด ๊ฐ๊ณผ์ ์ซ์ ๋น๊ต๋ฅผ ํตํด ์ ๋ ฌํ๋ ๊ฒ