Advertisement
AlbertMourato

Untitled

Nov 26th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3. using namespace std;
  4. int main(){
  5.     int moedas[] ={1, 5, 10, 25, 50};
  6.     int n;
  7.     cin>>n;
  8.     int matriz[5][n+1];
  9.     for(int i = 0; i<=n;i++){
  10.         matriz[1][i] = 1;
  11.     }
  12.     for(int i = 0; i<=5;i++){
  13.         matriz[i][0] = 1;
  14.     }
  15.     for(int i = 2; i<=5;i++){
  16.         for(int j = 0; j<=n;j++){
  17.             if(j==0){
  18.                 matriz[i][j] = matriz[i-1][j];
  19.             }else if(i<matriz[i][j]){
  20.                 matriz[i][j] = matriz[i-1][j];
  21.             }else{
  22.                 matriz[i][j] = matriz[i-1][j]+matriz[i][j-i];
  23.             }
  24.         }
  25.     }
  26.     for(int i= 0; i<=n;i++){
  27.         for(int j = 0; j<=5;j++){
  28.             cout<matriz[i][j];
  29.         }
  30.         cout<<"\n";
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement