|
![]() | 作者: upxshell [kuangren]
![]() |
登录 |
谁能帮我把下边的这段代码给解释一下,特别是这一行Overdue = yn != 'y'; 他代表的是什么意思 //////////////////////////////////////// // File Name: pr02013.cpp //////////////////////////////////////// #include <iostream> //////////////////////////////////////// // The main() function. //////////////////////////////////////// int main() { float Dues; // dues amount // Read the dues. std::cout << "Enter dues amount: "; std::cin >> Dues; // Are the dues paid on time? std::cout << "On time? (y/n) "; char yn; std::cin >> yn; bool Overdue; // true if overdue, false if on time Overdue = yn != 'y'; float AmountDue; // amount to be computed // Use conditional operator to compute. AmountDue = Overdue ? Dues * 1.10 : Dues; // Display the dues amount. std::cout << "Amount due: "; std::cout << AmountDue; return 0; } |
地主 发表时间: 06/23 15:07 |
![]() | 回复: hhj [hhj100] ![]() |
登录 |
Overdue =( yn != 'y';) 明白了吗? 赋值运算优先级低 |
B1层 发表时间: 06/23 18:51 |
![]() | 回复: upxshell [kuangren] ![]() |
登录 |
谢谢,已经明白了 |
B2层 发表时间: 06/24 09:07 |
![]() | 回复: aotianying [aotianying] ![]() |
登录 |
仔细看就知道了 |
B3层 发表时间: 06/29 20:39 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号