C++语言开发示例:05. foreach循环

2024-07-14 07:57:38 2025-02-01 20:27:54 李腾 22 次阅读 0 次点赞

forrange.cpp

#include <iostream>

int main()
{
    double prices[5] = {4.99, 10.99, 6.87, 7.99, 8.49};
    for (double x : prices)
    {
        std::cout << x << " ";
    }
    std::cout << std::endl;

    for (double &x : prices)
    {
        x = 1;
    }
    for (double x : prices)
    {
        std::cout << x << " ";
    }
    std::cout << std::endl;
}
本文由人工编写,AI优化,请仔细甄别,转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:05. foreach循环

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!