-
-
Save Jeremywu0109/c970c93423e202465c384226a1626625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(int argc, char** argv) | |
{ | |
int a[5]={0}, i = 0, x; | |
for (i = 0; i <= 4;i++) | |
{ | |
cout << "Integer" << i+1 << ":"; | |
cin >> x; | |
if(x>10||x<1) | |
{ | |
i--; | |
continue; | |
} | |
a[i] = x; | |
} | |
cout << "Array:"; | |
for (i = 0; i <= 4;i++) | |
{ | |
cout << a[i]; | |
if(i<4) | |
cout << " "; | |
} | |
cout << endl; | |
cout << "Reverse:"; | |
for (i = 4; i >= 0; i--) | |
{ | |
cout << a[i]; | |
if(i>=1) | |
cout << " "; | |
} | |
cout << endl; | |
cout << "Arrayeven:"; | |
for (i = 0; i <= 4;i++) | |
{ | |
int r = 0; | |
if(a[i]%2==0) | |
{ | |
cout << a[i]; | |
r++; | |
} | |
while(r>0) | |
{ | |
cout << " "; | |
r--; | |
} | |
} | |
cout << endl; | |
cout << "Arraysame:"; | |
for (int i = 0; i <= 4;i++) | |
{ | |
if(a[i]==i) | |
cout << a[i] << " "; | |
} | |
cout << endl; | |
cout << "Min:"; | |
int key; | |
i = 0; | |
key = a[i]; | |
for (i = 0; i < 4 ;i++) | |
{ | |
if(a[i]>a[i+1]) | |
key = a[i + 1]; | |
} | |
cout << key; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment