标准c库代码,可以应用于各个系统提供了大量的基本函数

源代码在线查看: div.c

软件大小: 1377 K
上传用户: IsabellaJ
关键词: 标准 代码 应用于 函数
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*				FUNCTION				---divide two integers								INDEX					div								ANSI_SYNOPSIS					#include 					div_t div(int , int );								TRAD_SYNOPSIS					#include 					div_t div(, )					int , ;								DESCRIPTION				Divide				@tex				$n/d$,				@end tex				@ifinfo				/,				@end ifinfo				returning quotient and remainder as two integers in a structure .								RETURNS				The result is represented with the structure								. typedef struct				. {				.  int quot;				.  int rem;				. } div_t;									where the  field represents the quotient, and  the					remainder.  For nonzero , if `' then					 equals `'.									When  is zero, the  member of the result has the same					sign as  and the largest representable magnitude.									To divide  rather than  values, use the similar					function .								PORTABILITY					 is ANSI, but the behavior for zero  is not specified by					the standard.								No supporting OS subroutines are required.				*/								#include 				#include 								div_t				_DEFUN (div, (n, d),					int n _AND					int d)				{				  div_t res;								  if (d)				    {				      res.quot = abs (n) / abs (d);				      res.rem = abs (n) % abs (d);								      if ((n < 0 && d > 0) || (n >= 0 && d < 0))					res.quot = -res.quot;				      if (n < 0)					res.rem = -res.rem;				    }				  else				    {				      if (n < 0)					res.quot = INT_MIN;				      else					res.quot = INT_MAX;								      res.rem = 0;				    }								  return res;				}							

相关资源