Update code.c

This commit is contained in:
2025-11-19 15:50:28 +07:00
committed by GitHub
parent 6ac1fb47da
commit b77d49c42c
+13 -12
View File
@@ -29,23 +29,23 @@ int main() {
case'a':case'A':
setmass(&massSize);
break;
case'b':case'B':
if(massSize!=0){massCreated = fillmass(
massSize,massive);flush();}
else printf("\n\tSet massive size first.\n\n");
break;
case'c':case'C':
if(massCreated){viewmass(massSize,massive);}
else printf("\n\tFill Massive first.\n\n");
break;
case'd':
if(massCreated){selfunc(massive);flush;}
else printf("\n\tFill Massive first.\n\n");
break;
case'g':case'G':
q=0;break;
@@ -93,21 +93,23 @@ int fillmass(int size, int *massive){
while(((x = getchar()) != '\n' && x !=' '
&& x != EOF && x != 4)
&& ((x>='0' && x<='9')
|| x == 'e' || x == '-'))
|| x == 'e' || (x == '-' && e==0 && massive[i]==0)))
{
if (x == 'e')e1=1;
else if (x == '-')minus=1;
else if (e1) e = (e*10)+(x-'0');
else if (x == '-' && massive[i]==0)minus=1;
else massive[i] = (massive[i]*10) + (x-'0');
}
if(x == EOF || x == 3){return 0;}
if(e1&&minus)minus=0;
if(minus && (x == '\n' || x == ' ')){minus = 0; massive[i]*=-1;}
if(e>size) printf("e is out of range.\n");
if(e>size) {printf("e is out of range.\n");i=p;}
else if(e1) {i = e - 1;putchar('\n');}
if(x == 'g'){return 1;}
if(x!='\n' && x!=' ' && x!='e' && x!='-' && !(x>='0'&&x<='9'))
{while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4);i--;}
if((x<='0' && x>='9')||x==' '||x=='\n'||x>=32);
else {while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4);i--;}
if(p!=i&&e1!=1)
printf("Massive - [%d]\t%d\n",i,massive[i]);
p=i;
@@ -119,7 +121,7 @@ int fillmass(int size, int *massive){
void viewmass(int size, int *massive){
printf("\t\tView Massive\n");
for(int i = 0; i < size; i++){
printf(" | [%6d]\t%p\t%d\n",i,massive[i],massive[i]);
printf(" | [%6d]\t%p\t%d\n",i,&massive[i],massive[i]);
}
}
@@ -145,7 +147,6 @@ void selfunc(int *massive){
flush();
return;
switch(n){
case 1:
}
}
@@ -155,4 +156,4 @@ int flush(void){
while((x = getchar())!='\n' && x!=4 && x!=1)
if(x==EOF)return 1;
return 0;
}
}