int m, i;int mayor(long array[]){ int m=0; for(;i<10;){ if(array[i]>m){ m=array[i]; } i=i+1; } i=0; cout<<"Mayor:"<<m<<endl; return m; }int menor(int n){ for(;i<10;){ if(array[i]<n){ n=array[i]; } i=i+1; } cout<<"Menor:"<<n<<endl; return n;}
#include <stdio.h>void main(){int a, b, c;printf("Ingrese 3 numeros ENTEROS diferentes: \n\n");printf("Valor 1: ");scanf("%d", &a);printf("Valor 2: ");scanf("%d", &b);printf("Valor 3: ");scanf("%d", &c); if(a<b){ if(a>c){ printf("%d %d %d\n",b ,a ,c); }else if(c<b){ printf("%d %d %d\n",b ,c ,a); }else{ printf("%d %d %d\n",c ,b ,a); } }else if(b>c){ printf("%d %d %d\n",a ,b ,c); }else if(c<a){ printf("%d %d %d\n",a ,c ,b); }else{ printf("%d %d %d\n",c ,a ,b); }system("PAUSE");}
#include <stdio.h> void main(){ int a, b, may, men, prim, val,i,bandera, bandera2, acum=0; float prom; printf("Ingrese la cantidad de numero que va a usar(Mayor o igual a DOS): "); scanf("%d",&val);bandera=1;bandera2=0; for(i=1;i<=val;i++){ printf("\n\nIngrese valor : "); scanf("%d", &a);acum=acum+a; if(bandera==1){ prim=a; bandera=0; } if(bandera2==1){ if(prim>a){ may=prim; if(i==2){men=a;}else{ if(men>a){ men=a; }} }else { may=a ; if(i==2){ men=prim; }else{ if(prim < men){ men=prim;}} prim=a; } } bandera2=1; } prom=(acum/val); printf("\nEl numero mayor es: %d\n\n",may); printf("El numero menor es: %d\n\n",men); printf("El promedio es: %.2f\n\n",prom);system("PAUSE"); }