MasterGun

LinearSort

Mar 21st, 2021 (edited)
500
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void linearSort(const int size,int arr[],int a){
  2.     for (int i = 0; i++, i < size;) {
  3.         if (arr[i] == a) {
  4.             cout << i << endl;
  5.             return;
  6.         }
  7.         cout << "ERROR #01, chosen number not found" << endl;
  8.     }
  9.  
  10. int main(){
  11.     setlocale(LC_ALL, "rus");
  12.     int a = 2;
  13.     const int size = 10;
  14.     int arr[10] = {2,5,3,6,1,9,2,10,7,8};
  15.     linearSort(size, arr, a);
  16.     return 0;
  17. }
RAW Paste Data