Advertisement
Guest User

Untitled

a guest
May 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. // Projekt2.cpp: Określa punkt wejścia dla aplikacji konsoli.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include <ctype.h>
  7. #include <stdlib.h>
  8.  
  9. int main()
  10. {
  11. char c;
  12. int i = 0;
  13. printf("Podaj trzy liczby calkowite:\n");
  14. for (;;) {
  15. c = getchar();
  16.  
  17. //skok:
  18. if (isdigit(c)) {
  19. if (c == '0') {
  20. printf("Blad - liczba zaczyna sie od 0\n");
  21.  
  22. do {
  23. c = getchar();
  24. }
  25. while (isdigit(c));
  26. if (c != ' ' && c != '\t') {
  27. printf("Blad - podano znak niedozwolony\n");
  28. i = 0;
  29. c = getchar();
  30. goto skok2;
  31. }
  32. i = 0;
  33. //goto skok;
  34. }
  35. while (c != ' ' && c != '\n') {
  36.  
  37. if (c == '.') {
  38. c = getchar();
  39. if (isdigit(c)) {
  40. printf("Blad - liczba nie jest liczba calkowita\n");
  41. i = 0;
  42. break;
  43. }
  44. }
  45.  
  46. else if (!isdigit(c) && c != ' ' && c!='\t') {
  47. printf("Blad - podano znak niedozwolonyxxxx\n");
  48. i = 0;
  49. break;
  50. }
  51. c = getchar();
  52. }
  53. i++;
  54. skok2:
  55. if (c == '\n') {
  56. if (i == 3) {
  57. printf("Liczby zostaly wpowadzone poprawnie\n");
  58. exit(0);
  59. }
  60. printf("Blad - za malo poprawnych liczb\n");
  61. i = 0;
  62. continue;
  63. }
  64.  
  65. continue;
  66. }
  67.  
  68. else if (c == ' ')
  69. continue;
  70. else if (c == '\n') {
  71. printf("Blad - brak liczb\n");
  72. continue;
  73. }
  74.  
  75. else {
  76. printf("Blad - podano znak niedozwolony (inny od cyfry lub spacji)\n");
  77. i = 0;
  78. continue;
  79. }
  80.  
  81. }
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement