且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在c ++控制台应用程序中显示数组

更新时间:2023-11-13 14:02:40

例如,下面的代码示例演示了如何在没有循环的情况下打印数组:

For example the following code example demonstrates how to print array without loop:
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

int main()
{
  short arr[] = { 10, 20, 30, 40 };

  copy(arr,arr + sizeof(arr) / sizeof(arr[0]),ostream_iterator<short>(cout,"\n"));
}


嗨亲爱的朋友

以下代码可以显示你的字符串,没有任何循环:



hi dear friend
with below code you can display your string without any loop:

<pre lang="c++">
char a[5]="hello";
printf("%s",a);