Advertisement
apfel2kuchen

Größere Zahl Ausgeben

Aug 20th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. //Größere Zahl Ausgeben
  2. #include<stdio.h>
  3. main()
  4. {
  5.  
  6. int z1,z2,z3;
  7.  
  8. z1 = 0;
  9. z2 = 0;
  10. z3 = 0;
  11.  
  12. printf("Geben Sie 3 Zahlen ein, die kleinste wird zuerst ausgeben\n");
  13. printf("Geben Sie die 1 Zahl ein: ");
  14. scanf("%d", &z1);
  15. printf("Geben Sie die 2 Zahl ein: ");
  16. scanf("%d", &z2);
  17. printf("Geben Sie die 3 Zahl ein: ");
  18. scanf("%d", &z3);
  19.  
  20. printf("\n");
  21. printf("%d, %d, %d\n",z1,z2,z3);
  22.  
  23. if (z1 > z2 && z1 > z3) {
  24. if ( z2 > z3) {
  25. printf("%d\n", z3);
  26. printf("%d\n", z2);
  27. printf("%d\n", z1);
  28. }
  29. else {
  30. printf("%d\n", z2);
  31. printf("%d\n", z3);
  32. printf("%d\n", z1);
  33. }
  34. }
  35. //Prüfen ob z2 die Höchstzahl ist
  36. else if (z2 > z1 && z2 > z3) {
  37. if ( z1 > z3) {
  38. printf("%d\n", z3);
  39. printf("%d\n", z1);
  40. printf("%d\n", z2);
  41. }
  42. else {
  43. printf("%d\n", z1);
  44. printf("%d\n", z3);
  45. printf("%d\n", z2);
  46. }
  47. }
  48. //Prüfen ob z3 die Höchstzahl ist
  49. else if (z3 > z1 && z3 > z2) {
  50.  
  51. if ( z1 > z2) {
  52. printf("%d\n", z2);
  53. printf("%d\n", z1);
  54. printf("%d\n", z3);
  55. }
  56. else {
  57. printf("%d\n", z1);
  58. printf("%d\n", z2);
  59. printf("%d\n", z3);
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement