necesito que los arreglos d emi programa sean locales y no globales como yo los tengo, lo he intentado pero no puedo....ayuda please lo ocupo urgente!!!!!
#include"stdio.h"
#include"conio.h"
#define N 3
#include"string.h"
char lista [N][4][30];
char resp;
char m[30];
void leer(int);
void buscar(char*,int,int);
char mod(char*,char*,int,int);
void cap_cal(int,int);
float cal[N][4];
void main()
{
int opcion,n=0,y;
char d,a;
while(1)
{
do
{
clrscr();
printf("\n\t1.Entrada de datos alumnos\n");
printf("\n\t2.B£squeda por No. de m3B
char m[30];
void leer(int);
void buscar(char*,int,int);
char mod(char*,char*,int,int);
void cap_cal(int,int);
float cal[N][4];
void main()
{
int opcion,n=0,y;
char d,a;
while(1)
{
do
{
clrscr();
printf("\n\t1.Entrada de datos alumnos\n");
printf("\n\t2.B£squeda por No. de matr¡cula\n");
printf("\n\t3.B£squeda por apellidos\n");
printf("\n\t4.Modificaciones\n");
printf("\n\t5.Calificaciones\n");
printf("\n\t6.Salir\n");
printf("\n\tTeclee la opcion deseada.....");
scanf("%d%*c",&opcion);
}
while(opcion<1 || opcion >6);
if(opcion!=6)
{
switch (opcion)
atr¡cula\n");
printf("\n\t3.B£squeda por apellidos\n");
printf("\n\t4.Modificaciones\n");
printf("\n\t5.Calificaciones\n");
printf("\n\t6.Salir\n");
printf("\n\tTeclee la opcion deseada.....");
scanf("%d%*c",&opcion);
}
while(opcion<1 || opcion >6);
if(opcion!=6)
{
switch (opcion)
{
case 1:
resp='s';
while(resp=='s' || resp=='S')
{
leer(n++);
}
break;
case 2:
clrscr();
printf("Introduce El N£mero De Matr¡cula..... ");
gets(m);
buscar(m,0,n);
break;
case 3:
clrsc {
case 1:
resp='s';
while(resp=='s' || resp=='S')
{
leer(n++);
}
break;
case 2:
clrscr();
printf("Introduce El N£mero De Matr¡cula..... ");
gets(m);
buscar(m,0,n);
break;
case 3:
clrscr();
printf("Introduce Los Apellidos..........");
gets(m);
buscar(m,1,n);
break;
case 4:
clrscr();
printf("Introduce El N£mero De Matr¡cula..... ");
gets(m);
buscar(m,0,n);
if(d=='n')
{continue;}
printf("\nModificar s/n...");
resp=getche();
if%r();
printf("Introduce Los Apellidos..........");
gets(m);
buscar(m,1,n);
break;
case 4:
clrscr();
printf("Introduce El N£mero De Matr¡cula..... ");
gets(m);
buscar(m,0,n);
if(d=='n')
{continue;}
printf("\nModificar s/n...");
resp=getche();
if(resp=='s' || resp=='S')
{
mod(&a,m,0,n);
}
break;
case 5:
begin:
clrscr();
printf("\n\t1.Introducir calificaciones\n");
printf("\n\t2.Ver calificaciones y promedio\n");
printf("\n\t3.Salir\n");
printf("\n\tTeclee la opcion deseada.....");
scanf("28resp=='s' || resp=='S')
{
mod(&a,m,0,n);
}
break;
case 5:
begin:
clrscr();
printf("\n\t1.Introducir calificaciones\n");
printf("\n\t2.Ver calificaciones y promedio\n");
printf("\n\t3.Salir\n");
printf("\n\tTeclee la opcion deseada.....");
scanf("%d%*c",&opcion);
if(opcion==1)
{
clrscr();
y=1;
cap_cal(n,y);
goto begin;
}
if(opcion==2)
{
clrscr();
y=0;
cap_cal(n,y);
goto begin;
}
if(opcion!=1 && opcion!=2)
break;
}
}
else
%d%*c",&opcion);
if(opcion==1)
{
clrscr();
y=1;
cap_cal(n,y);
goto begin;
}
if(opcion==2)
{
clrscr();
y=0;
cap_cal(n,y);
goto begin;
}
if(opcion!=1 && opcion!=2)
break;
}
}
else
{
clrscr();
gotoxy(35,10);printf("....A&N....");
gotoxy(35,11);printf(" SOFTWARE ");
getche();
break;}
}
}
void leer(int n)
{
int dif,j;
do
{
do
{
clrscr();
printf("Alumno n£mero %d\n\n",n+1);
printf("N£mero de matricula....... ");
gets(lista[n][0])%3{
clrscr();
gotoxy(35,10);printf("....A&N....");
gotoxy(35,11);printf(" SOFTWARE ");
getche();
break;}
}
}
void leer(int n)
{
int dif,j;
do
{
do
{
clrscr();
printf("Alumno n£mero %d\n\n",n+1);
printf("N£mero de matricula....... ");
gets(lista[n][0]);
if(n>0)
{
for(j=0;j<n;j++)
{dif=strcmp(lista[n][0],lista[j][0]);}
if(dif==0 || dif<0)
{
do
{
printf("Alumno ya existente.\n Introduce la Matricula de nuevo... ");
gets(lista[n][0]);
j=n;
while(j>0) {dif=strcmp(lista[n][0],lista[j--][0]);}
}
%B
if(n>0)
{
for(j=0;j<n;j++)
{dif=strcmp(lista[n][0],lista[j][0]);}
if(dif==0 || dif<0)
{
do
{
printf("Alumno ya existente.\n Introduce la Matricula de nuevo... ");
gets(lista[n][0]);
j=n;
while(j>0) {dif=strcmp(lista[n][0],lista[j--][0]);}
}
while(dif==0 || dif<0);
}
}
printf("Apellidos...... ");
gets(lista[n][1]);
printf("Nombre......... ");
gets(lista[n][2]);
printf("Direccion...... ");
gets(lista[n][3]);
printf("\n\n Datos correctos?? s/n...... ");
resp=getche();
}
while(resp=='n'|| resp=='N');
pr09 while(dif==0 || dif<0);
}
}
printf("Apellidos...... ");
gets(lista[n][1]);
printf("Nombre......... ");
gets(lista[n][2]);
printf("Direccion...... ");
gets(lista[n][3]);
printf("\n\n Datos correctos?? s/n...... ");
resp=getche();
}
while(resp=='n'|| resp=='N');
printf("\n\n OTRO?? s/n...... ");
resp=getche();
n++;
}
while(resp=='s'|| resp=='S');
}
#define NO 0
#define SI 1
void buscar(char x[30],int col,int alumnos)
{
int existe=NO, i=0,j,comp;
while(!existe && i <= alumnos)
{
comp= strcmp(lista[i++][col], x);
if (comp == 0)
eintf("\n\n OTRO?? s/n...... ");
resp=getche();
n++;
}
while(resp=='s'|| resp=='S');
}
#define NO 0
#define SI 1
void buscar(char x[30],int col,int alumnos)
{
int existe=NO, i=0,j,comp;
while(!existe && i <= alumnos)
{
comp= strcmp(lista[i++][col], x);
if (comp == 0)
existe = SI;
}
if(existe)
{
printf("\nNo. Matr¡cula... %s\nNombre... %s\nApellidos... %s\nDirecci¢n... %s\n",lista[i-1][0],lista[i-1][1],lista[i-1][2],lista[i-1][3]);
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
else
{ printf("\n%s No existe",x);
printf("\n\nPulse una tecla para continuar");
xiste = SI;
}
if(existe)
{
printf("\nNo. Matr¡cula... %s\nNombre... %s\nApellidos... %s\nDirecci¢n... %s\n",lista[i-1][0],lista[i-1][1],lista[i-1][2],lista[i-1][3]);
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
else
{ printf("\n%s No existe",x);
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
}
char mod(char *modify,char k[30],int col,int alum)
{
int existe=NO, i=0,j,comp,dif;
while(!existe && i <= alum)
{
comp= strcmp(lista[i++][col], k);
if (comp == 0)
existe = SI;
}
if(existe)
{
printf("\nN£mero de matricula....... ");
gets(lista[i-1][0])%3
resp=getch();
}
}
char mod(char *modify,char k[30],int col,int alum)
{
int existe=NO, i=0,j,comp,dif;
while(!existe && i <= alum)
{
comp= strcmp(lista[i++][col], k);
if (comp == 0)
existe = SI;
}
if(existe)
{
printf("\nN£mero de matricula....... ");
gets(lista[i-1][0]);
if(i>0)
{
for(j=0;j<i;j++)
{dif=strcmp(lista[i-1][0],lista[j][0]);}
if(dif==0 || dif<0)
{
do
{
printf("\nAlumno ya existente.\n Introduce la Matricula de nuevo... ");
gets(lista[i-1][0]);
j=i;
while(j>0) {dif=strcmp(lista[i-1][0],lista[j--][0]);}
B
if(i>0)
{
for(j=0;j<i;j++)
{dif=strcmp(lista[i-1][0],lista[j][0]);}
if(dif==0 || dif<0)
{
do
{
printf("\nAlumno ya existente.\n Introduce la Matricula de nuevo... ");
gets(lista[i-1][0]);
j=i;
while(j>0) {dif=strcmp(lista[i-1][0],lista[j--][0]);}
}
while(dif==0 || dif<0);
}
}
printf("Apellidos...... ");
gets(lista[i-1][1]);
printf("Nombre......... ");
gets(lista[i-1][2]);
printf("Direccion...... ");
gets(lista[i-1][3]);
printf("\n\n Datos correctos?? s/n...... ");
resp=getche();
printf("\n\nPulse una tecla para continuar");
resp=getch()%3}
while(dif==0 || dif<0);
}
}
printf("Apellidos...... ");
gets(lista[i-1][1]);
printf("Nombre......... ");
gets(lista[i-1][2]);
printf("Direccion...... ");
gets(lista[i-1][3]);
printf("\n\n Datos correctos?? s/n...... ");
resp=getche();
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
else
{ printf("\n%s No existe",k);
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
return(*modify);
}
void cap_cal(int k,int s)
{
int j=0,i=0,l,mat;
char op;
float prom;
if(s!=0)
{
do
{
printf("\nIntroduce el numero de matr¡cula... ");
B
}
else
{ printf("\n%s No existe",k);
printf("\n\nPulse una tecla para continuar");
resp=getch();
}
return(*modify);
}
void cap_cal(int k,int s)
{
int j=0,i=0,l,mat;
char op;
float prom;
if(s!=0)
{
do
{
printf("\nIntroduce el numero de matr¡cula... ");
scanf("%f",&cal[j]);
for(l=1;l<=3;l++)
{
printf("\nIntroduce calificacion %d...",l);
scanf("%f",&cal[j][l]);
}
printf("Datos correctos s/n... ");
op=getche();
}
while(op=='n' || op=='N');
}
if(s==0)
{
printf("\nIntrod
scanf("%f",&cal[j]);
for(l=1;l<=3;l++)
{
printf("\nIntroduce calificacion %d...",l);
scanf("%f",&cal[j][l]);
}
printf("Datos correctos s/n... ");
op=getche();
}
while(op=='n' || op=='N');
}
if(s==0)
{
printf("\nIntroduce el numero de matr¡cula... ");
scanf("%d",&mat);
for(j=0;j<=k;j++)
{
if(mat==cal[j])
{s=1;}
}
if(s==1)
{
j=0;
for(l=1;l<=3;l++)
{
printf("Calificacion %d...%2.2f\n",l,cal[j][l]);
getche();
prom+=cauce el numero de matr¡cula... ");
scanf("%d",&mat);
for(j=0;j<=k;j++)
{
if(mat==cal[j])
{s=1;}
}
if(s==1)
{
j=0;
for(l=1;l<=3;l++)
{
printf("Calificacion %d...%2.2f\n",l,cal[j][l]);
getche();
prom+=cal[j][l];
}
prom=prom/3;
printf("\nPromedio....%2.2f",prom);
getche();
}
else
{printf("No existe");
getche();}
}
j++;
}
programa c++
Moderador: Moderadores