⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 div.c

📁 标准c库代码,可以应用于各个系统提供了大量的基本函数
💻 C
字号:
/*FUNCTION<<div>>---divide two integersINDEX	divANSI_SYNOPSIS	#include <stdlib.h>	div_t div(int <[n]>, int <[d]>);TRAD_SYNOPSIS	#include <stdlib.h>	div_t div(<[n]>, <[d]>)	int <[n]>, <[d]>;DESCRIPTIONDivide@tex$n/d$,@end tex@ifinfo<[n]>/<[d]>,@end ifinforeturning quotient and remainder as two integers in a structure <<div_t>>.RETURNSThe result is represented with the structure. typedef struct. {.  int quot;.  int rem;. } div_t;	where the <<quot>> field represents the quotient, and <<rem>> the	remainder.  For nonzero <[d]>, if `<<<[r]> = div(<[n]>,<[d]>);>>' then	<[n]> equals `<<<[r]>.rem + <[d]>*<[r]>.quot>>'.	When <[d]> is zero, the <<quot>> member of the result has the same	sign as <[n]> and the largest representable magnitude.	To divide <<long>> rather than <<int>> values, use the similar	function <<ldiv>>.PORTABILITY	<<div>> is ANSI, but the behavior for zero <[d]> is not specified by	the standard.No supporting OS subroutines are required.*/#include <limits.h>#include <stdlib.h>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;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -