어린알파카245
- 생활꿀팁생활Q. c# 코딩 문제 질문 있습니다.using System;class MainClass{ public static void Main(string[] args) { int[] arrayA = { 1, 2, 3, 4, 5 }; int[] arrayB = { 10, 20, 30, 40, 50 }; Console.WriteLine(Swap(arrayA, arrayB) == true); Console.WriteLine(Swap(Stringify(arrayA) == "10 20 30 40 50"); Console.WriteLine(Swap(Stringify(arrayB) == "1 2 3 4 5"); } }Console.WriteLine에 위의 세 함수를 넣은 결과가 true가 나와야 하는데 함수를 못 짜겠습니다. 몇 시간째 붙잡고 해 봐도 안 되네요...어떻게 하는 건가요?
- 생활꿀팁생활Q. c# 코드 짜는 중 궁금한 게 있습니다.using System;class MainClass{ public static void Main(string[] args) { Action print = Console.WriteLine; double a = 10.0, b = 20.0; Swap(ref a, ref b); print(a == 20.0 && b == 10.0); } static void Swap(ref double a, ref double b) { double temp; temp = a; a = b; b = temp; }}위 코드에서 Swap 함수 앞에 왜 static이 붙어야 하는지 궁금합니다. 그리고 만약 static을 사용하지 않으려면 어떻게 고쳐야 하는지도 궁금합니다.
- 생활꿀팁생활Q. c# 배열을 사용해서 코드를 짰는데 문제가 있는 듯합니다.아래 코드 중 print(Avg(scores) == 4.5); print(Max(scores) == 8); 이 두 코드의 논리값이 true여야 하는데 false로 나옵니다....뭐가 문제일까요?ㅠ using System;class MainClass { public static void Main (string[] args) { Action print = Console.WriteLine; int[] scores = new int[] {2,4,5,3,6,8,1,7}; print(Avg(scores) == 4.5); print(Max(scores) == 8); public static double Avg(int[] list) { int s = 0; foreach(int n in list) s += n; double a = s/list.Length; return a; } public static int Max(int[] list) { int Max = 0; for (int i = 0; i { if (list[i] Max = list[i]; } return Max; }
- 생활꿀팁생활Q. C# 코드 짜는 중 에러가 발생했습니다.이차방정식의 해를 구하는 코드를 짜고 있는데 오류가 발생했습니다. if문 전까지는 문제가 없는 거 확인했고 아마 if문이 문제인 듯합니다ㅠ 어디서 잘못된 걸까요?using System;class MainClass { public static void Main (string[] args) { double a, b, c, D; Console.WriteLine("2차 방정식 'ax^2 + bx + c'의 해 구하기"); Console.WriteLine("'a, b, c'의 값을 차례대로 입력하세요."); a = double.Parse(Console.ReadLine()); b = double.Parse(Console.ReadLine()); c = double.Parse(Console.ReadLine()); D = b*b-(4*a*c); if(D>0) { double x, y; x = (-b+(sqrt(b*b-4*a*c)))/(2*a); y = (-b-(sqrt(b*b-4*a*c)))/(2*a); Console.WriteLine(x); Console.WriteLine(y); } else if(D == 0) { int x; x =(-b/2*a); Console.WriteLine(x); } else { Console.WriteLine("해가 없습니다."); } }}
- 기타 고민상담고민상담Q. MBTI 검사는 실제 심리 상담에서 어느 정도 사용되나요?MBTI 검사는 실제 심리 상담에서 어느 정도 사용되나요? 검사 받아본 사람은 정말 많은데 실제로 어떤 분야에서, 어떤 용도로 사용되는지도 궁금합니다. 덧붙여 MBTI 말고도 신뢰할 만한 테스트는 어떤 게 있는지도 궁금합니다.
- 생활꿀팁생활Q. 코딩 문제 관련 질문입니다.(백준 10952번)https://www.acmicpc.net/problem/10952이 링크를 클릭하면 나오는 문제인데요, while 문을 사용해서 정수의 합을 출력하는 문제입니다. int main(void){ int a, b; while(1) { scanf("%d %d", &a, &b); printf("%d\n", a+b); if(a == 0 && b == 0) break; } return 0;}위의 코드는 는 제가 처음에 짠 코드로 printf가 scanf 바로 밑에 오게 짰습니다. 그런데 틀렸다고 나와서 다른 사람의 답을 참고해 보니 scanf 밑에 if를 먼저 쓰고, if 다음에 printf를 썼더군요. 어떤 차이가 있길래 제 답이 틀린 건가요? 아래의 코드가 정답입니다.int main(void){ int a, b; while(1) { scanf("%d %d", &a, &b); if(a == 0 && b == 0) break; printf("%d\n", a+b); } return 0;}