绝对值排序在提交时提醒Compilation Error咋修改
绝对值排序在提交时提示Compilation Error咋修改啊
------解决方案--------------------
把 13 行的 fabs 改成 abs
------解决方案--------------------
abs
Calculates the absolute value.
int abs( int n );
Routine Required Header Compatibility
abs <stdlib.h> or <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
The abs function returns the absolute value of its parameter. There is no error return.
Parameter
n
Integer value
Example
/* ABS.C: This program computes and displays
* the absolute values of several numbers.
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void main( void )
{
int ix = -4, iy;
long lx = -41567L, ly;
double dx = -3.141593, dy;
iy = abs( ix );
printf( "The absolute value of %d is %d\n", ix, iy);
ly = labs( lx );
printf( "The absolute value of %ld is %ld\n", lx, ly);
dy = fabs( dx );
printf( "The absolute value of %f is %f\n", dx, dy );
}
Output
The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -3.141593 is 3.141593
Data Conversion Routines
------解决方案--------------------
Floating-Point Support
See Also _cabs, fabs, labs
------解决方案--------------------
在VC 6.0上市可以正常运行的
------解决方案--------------------
貌似没有什么问题,试过没太大问题,起码能编译过,简单的case也能跑过。
AC平台用的什么编译器?
#include<stdio.h>
#include<math.h>
int main()
{
int n,i,j,t;
int a[101];
while(~scanf("%d",&n))
{ if(n==0) break;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
for(j=1;j<=n-i;j++)
if(fabs(a[j])<fabs(a[j+1]))
{t=a[j];a[j]=a[j+1];a[j+1]=t;}
for(i=1;i<=n;i++)
printf("%d ",a[i]);
printf("\n");
}
return 0;
}
------解决方案--------------------
把 13 行的 fabs 改成 abs
------解决方案--------------------
abs
Calculates the absolute value.
int abs( int n );
Routine Required Header Compatibility
abs <stdlib.h> or <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
The abs function returns the absolute value of its parameter. There is no error return.
Parameter
n
Integer value
Example
/* ABS.C: This program computes and displays
* the absolute values of several numbers.
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void main( void )
{
int ix = -4, iy;
long lx = -41567L, ly;
double dx = -3.141593, dy;
iy = abs( ix );
printf( "The absolute value of %d is %d\n", ix, iy);
ly = labs( lx );
printf( "The absolute value of %ld is %ld\n", lx, ly);
dy = fabs( dx );
printf( "The absolute value of %f is %f\n", dx, dy );
}
Output
The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -3.141593 is 3.141593
Data Conversion Routines
------解决方案--------------------
Floating-Point Support
See Also _cabs, fabs, labs
------解决方案--------------------
在VC 6.0上市可以正常运行的
------解决方案--------------------
貌似没有什么问题,试过没太大问题,起码能编译过,简单的case也能跑过。
AC平台用的什么编译器?