<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hola a todos:<BR>
mire aqui les adjunto el programa q esta hecho con el dev c++, para q me puedan ayudar, hice tantas modificaciones, pero nada sigue saltando el mismo error. <BR>
<BR>
gracias<BR>
atte:Laura Costabel<BR>
lista con clase C<BR>
<BR>
#include<stdio.h><BR>#include<conio.c><BR>#include<string.h><BR>
typedef char Cadena40 [40];<BR>Cadena40 nombres [100];<BR> <BR>/* <BR> * comparar implementa comparacion de nombres<BR> */<BR>int comparar(int i, int j) {<BR>// printf("%s - %s - %d \n", nombres[i], nombres[j], strcmp(nombres[i], nombres[j]));<BR> return strcmp(nombres[i], nombres[j]);<BR>} // end comparar()<BR>
/* <BR> * swap implementa el intercambio de valores<BR> */<BR>void swap(int i, int j) {<BR> char aux[40];<BR>// printf("%s - %s \n", nombres[i], nombres[j]);<BR> strcpy(aux, nombres[i]);<BR>// printf("Swap %s \n", aux);<BR> strcpy(nombres[i], nombres[j]);<BR> strcpy(nombres[j], aux);<BR>// printf("%s - %s \n", nombres[i], nombres[j]);<BR>} // end swap()<BR>
/* <BR> * ordenar implementa ordenamiento ascendente de nombres<BR> */<BR>void ordenar(int cantidadpersonas) {<BR> for (int i = 0; i < cantidadpersonas - 1; i++) {<BR> for(int j = i + 1; j < cantidadpersonas; j++) {<BR> // printf("%s - %s \n", nombres[i], nombres[j]);<BR> if(comparar(i, j) == 1) {<BR> swap(i, j);<BR> }<BR> }<BR> }<BR>} // end ordenar()<BR>
/* <BR> * mostrar implementa mostrar los nombres<BR> */<BR>void mostrar(int cantidadpersonas) {<BR> for (int i = 0; i < cantidadpersonas; i++) {<BR> printf("\n %d %s ", i, nombres[i]);<BR> }<BR> printf("\n Oprima return para continuar ...");<BR> getch();<BR>} // end mostrar()<BR>
/*<BR> * main Rutina principal<BR> */<BR>
<BR>//* Comparamos para la longitud<BR>int comlen(int i, int j) {<BR>// printf("%s - %s - %d \n", nombres[i], nombres[j], strcmp(nombres[i], nombres[j]));<BR> int a = strlen (nombres [i]);<BR> int b = strlen (nombres [j]);<BR> int c;<BR> if (a==b) c=0;<BR> else if (a<b) c=-1;<BR> else c=1; <BR> return c;<BR>} // end comparar()<BR>
//* Ordenamos para la longitud<BR>void ordlen(int cantidadpersonas) {<BR> for (int i = 0; i < cantidadpersonas - 1; i++) {<BR> for(int j = i + 1; j < cantidadpersonas; j++) {<BR> // printf("%s - %s \n", nombres[i], nombres[j]);<BR> if(comlen(i, j) == 1) {<BR> swap(i, j);<BR> }<BR> }<BR> }<BR>} // end ordenar()<BR>
<BR>int main () {<BR> int cantidadpersonas;<BR> // Ingresar cantidad de personas<BR> printf("\n Ingrese la cantidad de la lista de personas: ");<BR> scanf("%d",&cantidadpersonas);<BR> // Ingresar los nombres<BR> for (int i = 0; i < cantidadpersonas; i++) {<BR> printf("\n Introducir el nombre %d : ", i);<BR> scanf("%s", &nombres[i]);<BR> }<BR> // Mostrar nombres ingresados<BR> mostrar(cantidadpersonas);<BR> // Ordenar la lista de nombres<BR> ordenar(cantidadpersonas);<BR> // Mostrar lista ordenada<BR> printf("\n\n LISTA ORDENADA ALFABETICAMENTE\n");<BR> <BR> <BR> mostrar(cantidadpersonas);<BR> printf("\n\n LISTA ORDENADA POR LONGITUD\n");<BR> <FONT style="BACKGROUND-COLOR: #ffff00">//* printf("\n La longitud de\"%s\" es %d", nombres,strlen(nombres);// esto me da error no se porque</FONT><BR> <BR> ordlen(cantidadpersonas);<BR> // Mostrar lista ordenada <BR> mostrar(cantidadpersonas);<BR> return 0;<BR>} // end main()<BR><BR> <br /><hr />Guardá y compartí fotos, archivos, documentos y más. <a href='http://skydrive.live.com' target='_new'>¡Con Windows Live tienes 25 GB gratis! Probalo ahora.</a></body>
</html>