#include<iostream>
#include<cstdlib>
using namespace std;
int posicion_del_menor(int[],int);//prototipo
int main(){
int A[]={5,1,8,9,1,1,4,3};
cout<<posicion_del_menor(A,8)<<endl;
system("PAUSE");
}
//implementacion
int posicion_del_menor(int A[],int num){
int x;
int pos;
x=A[0]; pos=0;
for(int i=1;i<num;i++) {
if (x>=A[i]){
x=A[i];pos=i;
}
}
return pos;
}
#include<iostream>
#include<cstdlib>
using namespace std;
float evalua(int [],int,float );
int main(){
int p[]={5,1,8,9,1,1,4,3};//coeficientes
int n=7;//grado del polinomio
cout<<evalua(p,7,0.5)<<endl;
system("PAUSE");
}
float evalua(int A[],int n,float x){
/* p(x)=A[0]+x*t
t = A[1]+x*t
...
t=A[n-1]+x*t
t=A[n] */
float t=A[n];
for(int i=n-1;i>=0;i--){
t=A[i]+x*t;
}
return t;
}
#include<iostream>
#include<cstdlib>
using namespace std;
void imprime(int [],int );
int main(){
int p[]={5,-1,8,9,-1,1,4,3};//coeficientes
int n=7;//grado del polinomio
imprime(p,7);
system("PAUSE");
}
void imprime(int A[],int n){
for(int i=0;i<=n;i++){
string signo;
signo="-";
if ( (A[i]>0)&&(i>0)){
signo="+";
}
if (i==0)
cout<<signo<<abs(A[i]);
else {
if (abs(A[i])==1){
cout<<signo<<"x^"<<i;
}
else {
cout<<signo<<abs(A[i])<<"x^"<<i;
}
}
}
}
No hay comentarios:
Publicar un comentario