如何实现简单的C ++函数

时间:2017-12-27 12:41:05

标签: c++ arrays visual-studio

我想解决的编程挑战是:编写一个接受三个参数的函数:一个数组的大小 数组数字n 。假设数组包含整数。该函数应显示数组中大于数字n的所有数字。

{{1}}

到目前为止,这是我弄错的事情,但我不知道这是否与解决这一挑战的距离非常接近,也许专业C ++开发人员的一些指导会有所帮助。

编辑:我在评论中得到了你们的一些帮助,感谢你们帮助新手。那意义重大。

2 个答案:

答案 0 :(得分:2)

你可以这样做 -

<Button x:Name="Button1" Style="{StaticResource ButtonRevealStyle}">
<Button.Resources>
    <SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
</Button.Resources>

答案 1 :(得分:0)

#include "stdafx.h"
#include <iomanip>
#include <iostream> 
using namespace std; 
double largerThanN(int[], int size, int n);

int main() {
    int arr_size;    // array size
    cin >> arr_size;
    vector<int> arr(n);
    cout << "Enter values: ";
    for (int i=0; i<n; i++)
        cin >> arr[i];
    int n;
    cin >> n;       // the no. to search for
    largerThanN(arr, arr_size, n);
    return 0; }

void largerThanN(int[], int size, int n) {
    int index;
    for (index = 0; index < size; index++) 
    {
        if (values[index] > n)
            cout << values[n] << endl;
    } }