Debe ser algún algoritmo matemático conocido, pero implementado mediante colas, ¿no?
Bueno, estoy conjeturando ...
Bueno, estoy conjeturando ...

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int extract_token( FILE *, char * );
int isInt( const char * );
int main( ) {
char *file = "datos.txt";
char token[51];
FILE *fPtr;
/* Definiendo la estructura COORD, con capacidad para diez números */
struct COORD {
int x1[10];
int y1[10];
int x2[10];
int y2[10];
};
struct COORD P; /* objeto de tipo struct COORD */
int count = 0; /* lleva el conteo de miembros en COORD */
if ( ( fPtr = fopen(file, "r") ) == NULL )
return -1; /* error al abrir el fichero */
int status;
while ( !feof(fPtr) && !ferror(fPtr) ) {
*token = '\0'; /* inicializa cadena vacía */
extract_token( fPtr, token );
printf( "token: %s\n", token );
}
fclose( fPtr );
return 0;
}
/* Extrae un token del fichero.
* Devuelve 1 si finalizó el archivo o si reconoció un token valido.
* En cualquier otro caso, devuelve cero.
*/
int extract_token( FILE *fPtr, char *token ) {
char c;
size_t len;
while ( ( c = fgetc( fPtr ) ) != EOF ) {
//printf( "c: %c,\ttoken: %s\n", c, token );
/* ignorar espacios */
if ( isspace( c ) ) continue;
/* encontró parentesis, token reconocido y finalizar */
if ( *token == '\0' && c == '(' ) {
strcpy( token, "(" );
return 1;
}
/* encontró parentesis, token reconocido y finalizar */
if ( *token == '\0' && c == ')' ) {
strcpy( token, ")" );
return 1;
}
/* encontró coma, token reconocido y finalizar */
if ( *token == '\0' && c == ',' ) {
strcpy( token, "," );
return 1;
}
/* encontró '-' añadir al token, pero al haber tres '-' seguidos,
* finalizar */
if ( c == '-' ) {
strcat( token, "-" );
if ( !strcmp( token, "---" ) ) return 1;
continue;
}
/* encontró el primer carácter numérico, añadir a la cadena y continuar */
if ( *token == '\0' && isdigit(c) ) {
token[0] = c;
token[1] = '\0';
continue;
}
/* si token es una cadena numérica ... */
if ( isInt( token ) ) {
/* ... y se haya un nuevo carácter, añadir */
if ( isdigit( c ) ) {
len = strlen( token );
token[len] = c;
token[len + 1] = '\0';
}
/* ... sino, terminar */
else {
ungetc( c, fPtr ); /* "devuelve" el caracter al archivo */
return 1;
}
}
/* si es carácter no reconocido, terminar */
if ( !isspace(c) && !isdigit(c) && c != ',' && c != '(' && c != ')' && c != '-' )
return 0;
}
return 0;
}
/* Decide si la cadena corresponde a un numero entero */
int isInt( const char *s ) {
char *cPtr = (char *)s;
if ( *cPtr == '\0' ) return 0; /* devuelve 0 si la cadena es nula */
while ( *cPtr != '\0' ) {
if ( !isdigit( *cPtr ) ) return 0;
cPtr++;
}
return 1;
}
int main( ) {
char *file = "datos.txt";
char token[51];
FILE *fPtr;
/* Definiendo la estructura COORD, con capacidad para diez números */
#define MAX 10 /* <-- asignas el tamano maximo de cuartetos a leer */
struct COORD {
int x1[MAX];
int y1[MAX];
int x2[MAX];
int y2[MAX];
};
struct COORD P; /* objeto de tipo struct COORD */
int count = 0; /* lleva el conteo de miembros en COORD */
int i, k = 0;
if ( ( fPtr = fopen(file, "r") ) == NULL )
return -1; /* error al abrir el fichero */
while ( !feof(fPtr) && !ferror(fPtr) ) {
*token = '\0'; /* inicializa cadena vacía */
extract_token( fPtr, token );
//printf( "token: %s\n", token );
if ( isInt(token) && count < MAX) {
switch ( k % 4 ) {
case 0:
P.x1[count] = atoi(token);
break;
case 1:
P.y1[count] = atoi(token);
break;
case 2:
P.x2[count] = atoi(token);
break;
case 3:
P.y2[count] = atoi(token);
count++;
break;
}
k++;
}
}
printf( "x1\ty1\tx2\ty2\n----------------------------\n" );
for ( i = 0; i < count; i++ )
printf( "%d\t%d\t%d\t%d\n", P.x1[i], P.y1[i], P.x2[i], P.y2[i] );
fclose( fPtr );
return 0;
}
*(array + i)
for(i=0; i<t; i++, array++){
if(*mayor < *array) *mayor = *array;
if(*menor > *array) *menor = *array;
suma+= *array;
}
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,t,u;
int p;
char opcion; /* <--- te cambie opcion a tipo char */
printf("øøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøø\n");
printf(" BIENVENIDOS A LA TIENDITA DE LA ESQUINA\n");
printf("øøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøøø\n\n\n\n\n\n");
double TOTAL = 0;
opcion = 's';
while( opcion == 's' )
{
printf(" Que desea llevar?\n\n");
printf("1. Coca cola 600ml\n");
printf("2. Huevo 1kg\n");
printf("3. Sopa de fideo\n");
printf("4. Sopa maruchan\n");
printf("5. Azucar 1kg\n");
printf("6. Sal 1kg\n");
printf("7. pan blanco\n");
printf("8. Pan integral\n");
printf("9. Salchicas 1kg\n");
printf("10. Yogurth\n");
printf("11. Bubalo\n");
printf("12. Leche lala\n");
printf("13. Leche alpura\n");
printf("14. Jamon 1/4\n");
printf("15. Papas sabritas\n");
printf("16. Agua 1lt\n");
printf("17. Paleta payaso\n");
printf("18. Cigarros\n");
printf("19. Cerveza 1lt\n");
printf("20. Agua mineral 2lt\n");
scanf("%i",&p);
getchar();
if(p==1) {
printf(" son: $10");
TOTAL += 10; /* suma 10 al total */
}
else if(p==2) {
printf(" son: $28");
TOTAL += 28;
}
else if(p==3) {
printf(" son: $5");
TOTAL += 5;
}
else if(p==4) {
printf(" son: $8");
TOTAL += 8;
}
else if(p==5) {
printf(" son: $12");
TOTAL += 12;
}
else if(p==6) {
printf(" son: $8");
TOTAL += 8;
}
else if(p==7) {
printf(" son: $14");
TOTAL += 14;
}
else if(p==8) {
printf(" son: $19");
TOTAL += 19;
}
else if(p==9) {
printf(" son: $36");
TOTAL += 36;
}
else if(p==10) {
printf(" son: $8.50");
TOTAL += 8.50;
}
else if(p==11) {
printf(" son: $.50");
TOTAL += 0.50;
}
else if(p==12) {
printf(" son: $17");
TOTAL += 17;
}
else if(p==13) {
printf(" son: $19");
TOTAL += 19;
}
else if(p==14) {
printf(" son: $21");
TOTAL += 21;
}
else if(p==15) {
printf(" son: $9");
TOTAL += 9;
}
else if(p==16) {
printf(" son: $12");
TOTAL += 12;
}
else if(p==17) {
printf(" son: $9.50");
TOTAL += 9.5;
}
else if(p==18) {
printf(" son: $35");
TOTAL += 18;
}
else if(p==19) {
printf(" son: $30");
TOTAL += 19;
}
else if(p==20) {
printf("\n son: $20");
TOTAL += 20;
}
printf("\n\n\nDesea llevar algo mas s/n?: ");
scanf("%c",&opcion);
getchar();
if ( opcion != 's' ) opcion = 'n';
clrscr();
}
printf("Total:\t%.2lf\n", TOTAL);
getchar();
return 0;
}
#include <stdio.h>
#define MAX 30
void kelvin(float *grados ){
int i, float kel;
for( i = 0; i < MAX; i++ ){
kel = grados[i] + 273.15;
printf("%f\n", kel);
}
}
}