ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 21번
    인프런 알고리즘테스트 문제 2020. 8. 30. 18:01
    #include<iostream>
    #include<vector>
    using namespace std;
    
    
    int main() {
    	int wincheck = 0;
    	int arrsum = 0;
    	int arr2sum = 0;
    	vector<int> arr(10);
    	vector<int> arr2(10);
    
    	for (int i = 0; i < 2; i++)
    	{
    		for (int j = 0; j < 10; j++)
    		{
    			if (i == 0)
    			{
    				cin >> arr[j];
    			}
    			else if (i == 1)
    			{
    				cin >> arr2[j];
    			}
    		}
    	}
    	for (int i = 0; i < 10; i++)
    	{
    		if (arr[i] > arr2[i])
    		{
    			arrsum = arrsum + 3;
    			wincheck = i;
    		}
    		else if (arr[i] < arr2[i])
    		{
    			arr2sum = arr2sum + 3;
    			wincheck = i;
    		}
    		else if (arr[i] == arr2[i])
    		{
    			arrsum++;
    			arr2sum++;
    		}
    	}
    	if (arrsum > arr2sum)
    	{
    		cout << arrsum << " " << arr2sum << endl;
    		cout << 'A';
    	}
    	else if (arrsum < arr2sum)
    	{
    		cout << arrsum << " " << arr2sum << endl;
    		cout << 'B';
    	}
    	else if (arrsum == arr2sum)
    	{
    		if (arr[wincheck] > arr2[wincheck])
    		{
    			cout << arrsum << " " << arr2sum << endl;
    			cout << 'A';
    		}
    		else if(arr[wincheck] < arr2[wincheck])
    		{
    			cout << arrsum << " " << arr2sum << endl;
    			cout << 'B';
    		}
    		else if(wincheck==0)
    		{
    			cout << arrsum << " " << arr2sum << endl;
    			cout << 'D';
    		}
    	}
    
    
    }

    '인프런 알고리즘테스트 문제' 카테고리의 다른 글

    23번  (0) 2020.08.31
    22번  (0) 2020.08.31
    20번  (0) 2020.08.30
    19번  (0) 2020.08.29
    18번  (0) 2020.08.29
Designed by Tistory.