全部评论 2

  • #include <iostream>
    #include <cstdio>
    using namespace std;
    int a[] = {100, 50, 20, 10, 5, 2, 1};
    int main(){
    	int n;
    	cin >> n;
    	int ct = 0;
    	for(int i = 0; i < 7; i++){
    		ct += n / a[i];
    		n %= a[i];
    	}
    	cout << ct;
    
    	return 0;
    }
    
    
    

    2024-07-16 来自 广东

    0
  • #include <iostream>
    #include <cmath>
    using namespace std;
    int main(){
    int n, m100 = 0, m50 = 0, m20 = 0, m10 = 0, m5 = 0, m2 = 0;
    cin >> n;
    while(1){
    if(n / 100 > 0){
    n -= 100;
    m100 ++;
    }else if(n / 50 > 0){
    n -= 50;
    m50 ++;
    }else if(n / 20 > 0){
    n -= 20;
    m20 ++;
    }else if(n / 10 > 0){
    n -= 10;
    m10 ++;
    }else if(n / 5 > 0){
    n -= 5;
    m5 ++;
    }else if(n / 2 > 0){
    n -= 2;
    m2 ++;
    }else{
    break;
    }
    }
    cout << m100 << " " << m50 << " " << m20 << " " << m10 << " " << m5 << " " << m2 << " " << n;
    return 0;
    }

    2024-07-15 来自 浙江

    0
    • 没必要这么多吧,上课抄的
      #include <iostream>
      using namespace std;
      int main(){
      int n;
      cin>>n;
      cout<<n/100<<" ";
      cout<<n%100/50<<" ";
      cout<<n%100%50/20<<" ";
      cout<<n%100%50%20/10<<" ";
      cout<<n%100%50%20%10/5<<" ";
      cout<<n%100%50%20%10%5/2<<" ";
      cout<<n%100%50%20%10%5%2/1<<" ";
      return 0;
      }

      2024-07-16 来自 广东

      0

热门讨论