1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int input_array(int a[]){
int m;
int i;
char response = 'A';
cout << "Please input an integer : " << endl ;
cin >> m;
int b[m];
cout << "Do you want to input the " << m << " integers <Y/N> : " ;
cin >> response;
cout << response << endl;
if (response == 'Y'){
//cout << m;
for (i=0; i < m; i++){
cin >> b[i];
}
}
else if (response == 'N'){
cout << m;
//int random_number = 0;
for (i=0; i < m; i++){
b[i] = rand()%100;
//a[i] = {random_number};
}
}
a = b;
cout << a<<endl;
cout<<b<<endl;
cout << a<<endl;
return m;
}
int main()
{
int n = 0;
int j;
int* a;
int taille;
cout<<a<<endl;
taille = input_array(a);
cout<<a<<endl;
for (j = 0 ; j < taille ; j++){
cout << "bonjour";
cout << a[j]<<endl;
if (a[j] > a[0]){
cout << "salut";
swap (a[j], a[0]);
}
}
cout << a[1];
} |
Partager