So i have 2 lines of arrays. First line is M, second line is N. On the first line the user inputs 2 digits, first for the length of M, and second for the length of N. On the second line user inputs M, on the third - N. All i want is to display what elements of N are not contained in m, but in ascending order. Here's an example:
7 5
3.12 7.96 3.51 4.77 10.12 1.11 9.80
10.12 3.51 3.12 9.80 4.77
Output:
1.11 7.96
And here is my attempt at the program:
#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
int ifexists(double z[], int u, int v)
{
    int i;
    if (u == 0)
        return 0;
    for (i = 0; i <= u; i++)
        if (z[i] == v)
            return (1);
    return (0);
}
void main()
{
    double bills[100], paid[100], result[100];
    int m, n;
    int i, j, k;
    cin >> m >> n;
    if (n > m) {
        cout << "Wrong input.";
        exit(3);
    }
    for (int i = 0; i < m; i++) {
        cin >> bills[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> paid[i];
    }
    for (i = 0; i < n; i++)
        k = 0;
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            if (bills[i] == paid[j]) {
                break;
            }
        }
        if (j == n) {
            if (!ifexists(result, k, bills[i])) {
                result[k] = bills[i];
                k++;
            }
        }
    }
    for (i = 0; i < k; i++)
        cout << result[i] << " ";
}
The output i'm getting is almost correct - 7.96 1.11. Basically in reverse order. How can i flip this around? Also, chances are my report is too slow. Is there a way to increase the speed?
 
     
    