Professional Documents
Culture Documents
} #include <stdio.h>
printf("\n"); #include <math.h>
selectionSort(array, n); int main()
printf("Sorted array: \n"); {
for (int i = 0; i < n; i++) { int a, b, c, d;
printf("%d ", array[i]); double root1, root2;
} printf("Enter a, b and c where a*x*x + b*x + c =
printf("\n"); 0\n");
scanf("%d%d%d", &a, &b, &c);
d = b*b - 4*a*c;
if (d >= 0) {
root1 = (-b + sqrt(d))/(2*a);
root2 = (-b - sqrt(d))/(2*a);
printf("First root = %.2lf\n", root1);
printf("Second root = %.2lf\n", root2);
}
else {
printf("imaginary root");
}
return 0;
}
110 考古 參見第六章 Binary search of sorted array
第 40-68 行 變化題 6-33