while循化的两种形式

循化开始之前先进行一次初始化。

while (true) {
		scanf_s("%lf %d", &coefficient, &exponent);
		if (exponent == -1) break;
		m_CoefficientVector[exponent] = coefficient;
}

或者(逻辑更加明确)

scanf_s("%lf %d", &coefficient, &exponent);
while (exponent != -1) {
		m_CoefficientVector[exponent] = coefficient;
		scanf_s("%lf %d", &coefficient, &exponent);
}
发布了27 篇原创文章 · 获赞 1 · 访问量 1413

猜你喜欢

转载自blog.csdn.net/qq_34890856/article/details/104066066