美文网首页
C++的使用实例

C++的使用实例

作者: Co酱_秋乏术 | 来源:发表于2023-01-24 15:07 被阅读0次

    #include <iostream> using namespace std;

     int main()

    {

          floatapple price =3.5;//苹果单价,3.5元/公斤

          float banana_price=4.2;//香蕉单价,4.2元/公斤

          float apple_weight=0.0;//苹果重量,初始化为0 

          float banana_weight=0.0;//香蕉重量,初始化为0

          float total =0.0; //总钱数,初始化为0

          cout << "请输入苹果重量"<< endl;//提示信息

          cin >> apple weight//输入苹果重量

          cout << "请输入香蕉重量"<<endl;//提示信息 

          cin >> banana_weight;//输入香蕉重量 

          total=apple_price*apple_weight+banana_price*banana_weight;//计算应付款

          cout <<"应付款"<< total << endl;//输出应付款

           return 0 ;

    }


    逻辑推理问题,多重循环遍历可能的解:

    有六名嫌疑犯,他们的口供如下:

    A:我不是罪犯

    B:A、C中有一个是罪犯

    C:A和B说了假话

    D:C和F说了假话

    E:其他五个人中,只有A和D说了真话

    F:我是罪犯

    他们中只有一半说了真话,凶手只有一个。

    本题答案不唯一,请编程找出所有可能的凶手。

    相关文章

      网友评论

          本文标题:C++的使用实例

          本文链接:https://www.haomeiwen.com/subject/olozcdtx.html