Home > Back-end >  C struct array
C struct array

Time:06-03

#include
Struct stu
{
Double num.
Char manee [200].
Char zuozhe [100].
Float price;
};
Int main ()
{
Int n, I, j, e;
Double h;
Struct stu a, [100].
While (the scanf (" % d ", & amp; N)!=(EOF)
{
J=0;
for(i=0; i{
The scanf (" % 0 lf ", & amp; A [I] num);
For (e=0; A [I] manee [e]!='\ 0'; E++)
The scanf (" % c ", & amp; A [I] manee [e]);
The scanf (" % s % 2 f ", a [I] zuozhe, & amp; A [I]. Price);
}
The scanf (" % 0 lf ", h);
for(i=0; i{
If (a [I] num==h)
{
Printf (" % 0 lf ", a [I] num);
For (e=0; A [I] manee [e]!='\ 0'; E++)
Printf (" % c ", [I] a manee [e]);
Printf (" % s % 2 f \ n ", a [I] zuozhe, a [I] price);
j++;
break;
}
}
If (j==n)
Printf (" No find!" );
}
}
This program is what will timeout,
Runtime Error:Segmentation fault

CodePudding user response:

The
refer to the original poster qq_45982074 response:
# include
Struct stu
{
Double num.
Char manee [200].
Char zuozhe [100].
Float price;
};
Int main ()
{
Int n, I, j, e;
Double h;
Struct stu a, [100].
While (the scanf (" % d ", & amp; N)!=(EOF)
{
J=0;
for(i=0; i{
The scanf (" % 0 lf ", & amp; A [I] num);
For (e=0; A [I] manee [e]!='\ 0'; E++)
The scanf (" % c ", & amp; A [I] manee [e]);
The scanf (" % s % 2 f ", a [I] zuozhe, & amp; A [I]. Price);
}
The scanf (" % 0 lf ", h);
for(i=0; i{
If (a [I] num==h)
{
Printf (" % 0 lf ", a [I] num);
For (e=0; A [I] manee [e]!='\ 0'; E++)
Printf (" % c ", [I] a manee [e]);
Printf (" % s % 2 f \ n ", a [I] zuozhe, a [I] price);
j++;
break;
}
}
If (j==n)
Printf (" No find!" );
}
}
This program is what will timeout,
Runtime Error: Segmentation fault

Don't be to brush bottom go to, don't be brush down

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related