Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sortValues[13] = { 2, 7, 4, 6, 5, 3, 8, 10, 9, 11, 14, 12, 13 };
- int str1 = 50;
- int str2 = 150;
- int str3 = 40;
- int str4 = 80;
- //-------------------------
- void setup()
- {
- Serial.begin(9600);
- }
- //------------------------
- void loop()
- {
- sort(sortValues,13);
- Serial.print("Sorted Array: ");
- for(int i=0; i<13; i++)
- {
- Serial.print(sortValues[i]);
- Serial.print(",");
- }
- Serial.println("");
- Serial.print("Max Number: ");
- Serial.print(sortValues[12]);
- Serial.println("");
- Serial.print("Min Number: ");
- Serial.print(sortValues[0]);
- Serial.println("");
- delay(10000);
- }
- //----------------------------
- void sort(int a[], int size)
- {
- for(int i=0; i<(size-1); i++)
- {
- for(int o=0; o<(size-(i+1)); o++)
- {
- if(a[o] > a[o+1])
- {
- int t = a[o];
- a[o] = a[o+1];
- a[o+1] = t;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement