Update code.c
This commit is contained in:
+13
-12
@@ -29,23 +29,23 @@ int main() {
|
|||||||
case'a':case'A':
|
case'a':case'A':
|
||||||
setmass(&massSize);
|
setmass(&massSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case'b':case'B':
|
case'b':case'B':
|
||||||
if(massSize!=0){massCreated = fillmass(
|
if(massSize!=0){massCreated = fillmass(
|
||||||
massSize,massive);flush();}
|
massSize,massive);flush();}
|
||||||
else printf("\n\tSet massive size first.\n\n");
|
else printf("\n\tSet massive size first.\n\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case'c':case'C':
|
case'c':case'C':
|
||||||
if(massCreated){viewmass(massSize,massive);}
|
if(massCreated){viewmass(massSize,massive);}
|
||||||
else printf("\n\tFill Massive first.\n\n");
|
else printf("\n\tFill Massive first.\n\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case'd':
|
case'd':
|
||||||
if(massCreated){selfunc(massive);flush;}
|
if(massCreated){selfunc(massive);flush;}
|
||||||
else printf("\n\tFill Massive first.\n\n");
|
else printf("\n\tFill Massive first.\n\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case'g':case'G':
|
case'g':case'G':
|
||||||
q=0;break;
|
q=0;break;
|
||||||
|
|
||||||
@@ -93,21 +93,23 @@ int fillmass(int size, int *massive){
|
|||||||
while(((x = getchar()) != '\n' && x !=' '
|
while(((x = getchar()) != '\n' && x !=' '
|
||||||
&& x != EOF && x != 4)
|
&& x != EOF && x != 4)
|
||||||
&& ((x>='0' && x<='9')
|
&& ((x>='0' && x<='9')
|
||||||
|| x == 'e' || x == '-'))
|
|| x == 'e' || (x == '-' && e==0 && massive[i]==0)))
|
||||||
{
|
{
|
||||||
if (x == 'e')e1=1;
|
if (x == 'e')e1=1;
|
||||||
|
else if (x == '-')minus=1;
|
||||||
|
|
||||||
else if (e1) e = (e*10)+(x-'0');
|
else if (e1) e = (e*10)+(x-'0');
|
||||||
else if (x == '-' && massive[i]==0)minus=1;
|
|
||||||
else massive[i] = (massive[i]*10) + (x-'0');
|
else massive[i] = (massive[i]*10) + (x-'0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x == EOF || x == 3){return 0;}
|
if(x == EOF || x == 3){return 0;}
|
||||||
|
if(e1&&minus)minus=0;
|
||||||
if(minus && (x == '\n' || x == ' ')){minus = 0; massive[i]*=-1;}
|
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');}
|
else if(e1) {i = e - 1;putchar('\n');}
|
||||||
if(x == 'g'){return 1;}
|
if(x == 'g'){return 1;}
|
||||||
if(x!='\n' && x!=' ' && x!='e' && x!='-' && !(x>='0'&&x<='9'))
|
if((x<='0' && x>='9')||x==' '||x=='\n'||x>=32);
|
||||||
{while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4);i--;}
|
else {while((x=getchar())!='\n'&&x!=' '&&x!=EOF&&x!=4);i--;}
|
||||||
if(p!=i&&e1!=1)
|
if(p!=i&&e1!=1)
|
||||||
printf("Massive - [%d]\t%d\n",i,massive[i]);
|
printf("Massive - [%d]\t%d\n",i,massive[i]);
|
||||||
p=i;
|
p=i;
|
||||||
@@ -119,7 +121,7 @@ int fillmass(int size, int *massive){
|
|||||||
void viewmass(int size, int *massive){
|
void viewmass(int size, int *massive){
|
||||||
printf("\t\tView Massive\n");
|
printf("\t\tView Massive\n");
|
||||||
for(int i = 0; i < size; i++){
|
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();
|
flush();
|
||||||
return;
|
return;
|
||||||
switch(n){
|
switch(n){
|
||||||
case 1:
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,4 +156,4 @@ int flush(void){
|
|||||||
while((x = getchar())!='\n' && x!=4 && x!=1)
|
while((x = getchar())!='\n' && x!=4 && x!=1)
|
||||||
if(x==EOF)return 1;
|
if(x==EOF)return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user