首页 > 编程语言 >Loops in C++

Loops in C++

时间:2023-03-23 23:12:09浏览次数:41  
标签:std 20 int C++ Loops main

#include <iostream>
using namespace std;

int main() {
    int v[] = {0,1,2,3,4};
    for(auto x : v)
    {
        cout << x << endl;
    }

    for(auto y : {10, 20, 30})
    {
        cout << y << endl;
    }
    
    return 0;
}

输出:

0
1
2
3
4
10
20
30

标签:std,20,int,C++,Loops,main
From: https://www.cnblogs.com/symbolflowing/p/17249873.html

相关文章

  • when should we use struct in C++?
    InC++,structisakeywordusedtodefineadatastructurethatgroupsmultiplevariablesofdifferentdatatypesintoasingleunit.Herearesomesituations......
  • what are the primitive types of C++?
    InC++,thereareseveralprimitivedatatypes,whicharealsoknownasfundamentalorbuilt-indatatypes.Theseinclude:Integertypes:Usedtorepresentw......
  • how to learn C++?
    HerearesomestepstolearnC++:Learnthebasics:StartwiththebasicsofC++,includingvariables,datatypes,controlstructures,loops,andfunctions.......
  • C++ 内存池技术初探
    目录内存池意义单线程内存池全局函数new(),delete()局限性版本1:专用Rational内存管理器版本2:固定大小对象的内存池版本3:单线程可变大小内存管理器MemoryChunk内存块列表类......
  • C++中std::function常见用法
    C++标准库中的std::function是一个通用的函数封装,可以用来存储、复制、调用任何可调用对象(函数、函数指针、成员函数指针、lambda表达式等)。以下是std::function的一些常见......
  • 【C++入门】命名空间、缺省参数、函数重载
    前言在正式进入C++之前,我们首先要对C++有一个基本的认知。这里我就不过多的进行描述了,有兴趣的可以去网络搜索一番。总而言之,从名称上面我们也可以看得出来,C++是在C的基础上......
  • C++编程题(蓝桥杯)
        运行结果  #include<iostream>usingnamespacestd;voidjingsai1(){//chh:水深;chs:最初水下深度;intchh=0,chs=0;intI_depth=0;cou......
  • C++重载递增和递减运算符
    重载递增和递减运算符在迭代器类中通常会实现递增运算符(++)和递减运算符(--),这两种运算符使得类可以在元素的序列中前后移动。C++语言并不要求递增和递减运算符必须是类......
  • c++代码编译出错:undefined reference to `typeinfo for dnet::event_handler'
    编译出错信息如下:[82%]LinkingCXXexecutable../bin/dsys/usr/bin/ld:../lib/libdnet.so:undefinedreferenceto`typeinfofordnet::event_handler'collect2:er......
  • 指针常量和常量指针_C++_Learning1
    怎么读?遇到"*"读指针,遇到"const"读常量 一、指针常量//指针常量——指针(也就是它存储的地址)是一个常量,所以其值不能修改,但指向的内容可以修改 inta=10,b=......