打印在C ++中数组? [英] Printing an array in C++?
本文介绍了打印在C ++中数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有C印花阵列的方式++?
Is there a way of printing arrays in C++?
我想做出一个反向用户输入数组的函数,然后打印出来。我想谷歌搜索这个问题,它似乎像C ++不能打印阵列。这不可能是真的可以吗?
I'm trying to make a function that reverses a user-input array and then prints it out. I tried Googling this problem and it seemed like C++ can't print arrays. That can't be true can it?
推荐答案
你不能只遍历元素呢?像这样的:
can't you just iterate over the elements? like this:
for (int i = numElements - 1; i >= 0; i--)
cout << array[i];
请注意:由于马克西姆Egorushkin指出,这可能溢出。见下面他的意见为更好的解决方案。
Note: As Maxim Egorushkin pointed out, this could overflow. See his comment below for a better solution.
这篇关于打印在C ++中数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文