swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PttaaAZIDFAUq&categoryId=AV5PttaaAZIDFAUq&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


입력 받은 시간 중 시는 시 끼리 분은 분끼리 더해주고 while문을 돌며 분끼리 더한 값이 60 이상인 경우 분에서 60을 빼주고 시를 늘려준다. 

또한, 시는 12 시간제로 표시된다는 조건에 따라 더해준 시 값이 13이상인 경우 12를 빼주어 12시간제로 표시해준다.

 

 

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;

  for(int i=1; i<=t; i++){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int hour = a+c;
   int min = b+d;
   while(min>=60){
     min -=60;
     hour++;
   }
   while(hour>=13){
     hour-=12;
   }
   cout<<"#"<<i<<" "<<hour<<" "<<min<<"\n";
  }
}

 

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1948. 날짜 계산기  (2) 2021.02.18
[c++] 1959. 두 개의 숫자열  (0) 2021.02.18
[c++]1986. 지그재그 숫자  (0) 2021.02.18
[c++] 1970.쉬운 거스름돈  (0) 2021.02.18
[c++] 1989. 초심자의 회문 검사  (0) 2021.02.18

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PxmBqAe8DFAUq&categoryId=AV5PxmBqAe8DFAUq&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


주어진 조건 대로 1~N 까지 for문을 돌며 값이 짝수(i%2==0) 경우 합에서 빼주고, 그외에 수는 모두 더해준다.

 

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;

  for(int i=1; i<=t; i++){
    int n;
    cin>>n;
    int sum = 0;
    for(int j =1; j<=n; j++){
      if(j%2==0) sum -=j;
      else{
        sum+=j;
      }
    }
    cout<<"#"<<i<<" "<<sum<<"\n";    
  }
}

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1959. 두 개의 숫자열  (0) 2021.02.18
[c++] 1976. 시각 덧셈  (0) 2021.02.18
[c++] 1970.쉬운 거스름돈  (0) 2021.02.18
[c++] 1989. 초심자의 회문 검사  (0) 2021.02.18
[c++] 1984. 중간 평균값 구하기  (0) 2021.02.18

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PsIl6AXIDFAUq&categoryId=AV5PsIl6AXIDFAUq&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


주어진 화폐의 종류를 담은 배열을 생성하며, 주어진 금액에 대해 화폐단위를 나눠주며 화폐 종류당 사용된 개수를 벡터에 넣어준다.  사용된 화폐단위 *개수 만큼 금액에서 빼주며 모든 금액에 대해 진행한다. 

 

프로그래머스 문제 넘 어려워서 SWEA로 도망왔는데 나름 재밌담

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;
  int money[8]={50000,10000,5000,1000,500,100,50,10};
  
  for(int i=1; i<=t; i++){
    int n;
    cin>>n;
    vector<int> vec;
    for(int j=0; j<9; j++){
      int t = n/money[j];
      vec.push_back(t);
      n -=money[j]*t;
    }
    cout<<"#"<<i<<"\n";
    for(int i=0; i<vec.size()-1; i++){
      cout<<vec[i]<<" ";
    }
    cout<<"\n";  
  }
}

 

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1976. 시각 덧셈  (0) 2021.02.18
[c++]1986. 지그재그 숫자  (0) 2021.02.18
[c++] 1989. 초심자의 회문 검사  (0) 2021.02.18
[c++] 1984. 중간 평균값 구하기  (0) 2021.02.18
[c++] 1204. 최빈수 구하기  (0) 2021.02.18

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PyTLqAf4DFAUq&categoryId=AV5PyTLqAf4DFAUq&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


입력받은 문자열을 tmp 에 복사하고 reverse 함수를 사용하여 뒤집어준다.

그 다음 뒤집은 문자열과 입력받은 문자열이 일치하는 경우 1 출력 

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t; 
  for(int i=1; i<=t; i++){
    string str =" ";
    cin>>str;
    int ans = 0;
    string tmp = str;
    reverse(tmp.begin(),tmp.end());
    if(tmp == str){
      ans = 1;
    }else{
      ans = 0;
    }
    
    cout<<"#"<<i<<" "<<ans<<"\n";
  }

}

 

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1976. 시각 덧셈  (0) 2021.02.18
[c++]1986. 지그재그 숫자  (0) 2021.02.18
[c++] 1970.쉬운 거스름돈  (0) 2021.02.18
[c++] 1984. 중간 평균값 구하기  (0) 2021.02.18
[c++] 1204. 최빈수 구하기  (0) 2021.02.18

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5Pw_-KAdcDFAUq&categoryId=AV5Pw_-KAdcDFAUq&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


약간 구현 코드가 비효율적인거 같기도,, 

모든요소를 벡터로 받아서 정렬한 뒤  모두 더해준다.

그 다음 벡터의 맨 앞값과 맨 뒤 값 (최소,최대값) 을 제외한 합의 평균을 출력 

평균값을 반올림하기 위해 round 함수 사용 

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t; 
  for(int i=1; i<=t; i++){
    double sum = 0;
    vector<int> vec;
    for(int i=0; i<10; i++){
      int num;
      cin>>num;
      vec.push_back(num);
    }
    sort(vec.begin(),vec.end());
    for(auto& a :vec){
      sum+=a;
    }
    sum = sum-(vec.front()+vec.back());
    cout<<"#"<<i<<" "<<round(sum/8)<<"\n";
  }

}

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1976. 시각 덧셈  (0) 2021.02.18
[c++]1986. 지그재그 숫자  (0) 2021.02.18
[c++] 1970.쉬운 거스름돈  (0) 2021.02.18
[c++] 1989. 초심자의 회문 검사  (0) 2021.02.18
[c++] 1204. 최빈수 구하기  (0) 2021.02.18

swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13zo1KAAACFAYh&categoryId=AV13zo1KAAACFAYh&categoryType=CODE

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 


나온 점수들의 개수를 늘려준다. 

포인트는 출력 결과를  그 점수가 등장한 횟수가 아닌 값 자체를 출력해주어야 한다는 점

#include <bits/stdc++.h>

using namespace std;

int main(void){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t; 
  while(t--){
    int num;
    cin>>num;
    int arr[101] ={0,};
    for(int i=0; i<1000; i++){
      int n;
      cin>>n;
      arr[n]++;
    }
    int max_num = 0;
    int ans = 0;
    for(int i=0; i<101; i++){
      if(max_num <=arr[i]){
        max_num = arr[i];
        ans = i;
      }
    }
    cout<<"#"<<num<<" "<<ans<<"\n";
   
  }

}

'Algorithm > SWEA' 카테고리의 다른 글

[c++] 1976. 시각 덧셈  (0) 2021.02.18
[c++]1986. 지그재그 숫자  (0) 2021.02.18
[c++] 1970.쉬운 거스름돈  (0) 2021.02.18
[c++] 1989. 초심자의 회문 검사  (0) 2021.02.18
[c++] 1984. 중간 평균값 구하기  (0) 2021.02.18

+ Recent posts