Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Programação Estruturada
- //Lista de Exercícios 0 - Exercício 8
- #include<stdio.h>
- int calcularP(int b, int n){
- int p=0;
- for(int x=1;x<=n;x++){
- if(x==1){
- p=x+b;
- }else{
- if((x%2)==0) p*=x-b; else p*=x+b;
- }
- }
- return p;
- }
- int main(){
- setbuf(stdout,NULL);
- int b, n;
- printf("Entre com os valores de b e n respectivamente: ");
- scanf("%d%d",&b,&n);
- printf("P=%d",calcularP(b,n));
- }
Advertisement
Add Comment
Please, Sign In to add comment