Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- void bubbleSort(int tab[],int size)
- {
- for(int i=0;i<size;i++){
- for(int j=1;j<size-i;j++){
- if(tab[j-1]>tab[j]){
- swap(tab[j-1], tab[j]);
- }
- }
- }
- }
- int main(){
- int option;
- cin >> option;
- switch(option){
- case 1:{
- const int size = 6;
- double table[size];
- for(int i = 0; i < size; i++){
- cin >> table[i];
- while(table[i] <= 0 or table[i] >= 10){
- cin >> table[i];
- }
- }
- cout << "Resulting array: ";
- for(int i = 0; i < size; i++){
- cout << table[i] << " ";
- }
- }
- break;
- case 2:{
- const int size = 5;
- int tab[size];
- int tab1[size];
- for(int i=0;i<size;i++){
- cin>>tab[i];
- }
- bubbleSort(tab, size);
- for(int i=0;i<size;i++){
- cin>>tab1[i];
- }
- bubbleSort(tab1, size);
- int x = 0;
- for(int i=0;i<size;i++){
- if(tab[i] == tab1[i]){
- x= x + 1;
- }
- }
- if(x == 5){
- cout << "Equal.";
- }
- else{
- cout << "Different.";
- }
- }
- break;
- case 3:{
- cout << "program 3" << endl;
- }
- break;
- default:{
- cout << "Wrong task number." << endl;
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement