veto14

Q4Exercicios1

Mar 27th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int coeficiente(int a,int b);
  5.  
  6. int main(void){
  7. int a,b,coef;
  8. scanf("%d %d",&a,&b);
  9. while(b>a){
  10. printf("Reinsira os valores de a e b, relembrando que o segundo numero não pode ser maior que o primeiro.\n");
  11. scanf("%d %d",&a,&b);
  12. }
  13. coef = coeficiente(a,b);
  14. printf("%d",coef);
  15. return 0;
  16. }
  17.  
  18. int coeficiente(int a,int b){
  19. if(b==0 && a>=1){
  20. return 1;
  21. }
  22. if(a==b){
  23. return 1;
  24. }
  25. else{
  26. return coeficiente(a-1,b) + coeficiente(a-1,b-1);
  27. }
  28. }
Add Comment
Please, Sign In to add comment