Demo entry 6760830

122

   

Submitted by anonymous on Sep 18, 2018 at 12:19
Language: C. Code size: 238 Bytes.

/* atio函数:将字符串s转换为相应的整形数 */

int atio(char s[])
{
	int i, n;

	n = 0;
	for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
		n = 10 * n + (s[i] - '0'); /*表达式s[i] - '0'能够计算s[i]中存储的字符所对应的数字符,因为'0'、'1'等在字符集中对应的数值是一个连续的递增序列 */
	return n;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).