Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Projekt2.cpp: Określa punkt wejścia dla aplikacji konsoli.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- int main()
- {
- char c;
- int i = 0;
- printf("Podaj trzy liczby calkowite:\n");
- for (;;) {
- c = getchar();
- //skok:
- if (isdigit(c)) {
- if (c == '0') {
- printf("Blad - liczba zaczyna sie od 0\n");
- do {
- c = getchar();
- }
- while (isdigit(c));
- if (c != ' ' && c != '\t') {
- printf("Blad - podano znak niedozwolony\n");
- i = 0;
- c = getchar();
- goto skok2;
- }
- i = 0;
- //goto skok;
- }
- while (c != ' ' && c != '\n') {
- if (c == '.') {
- c = getchar();
- if (isdigit(c)) {
- printf("Blad - liczba nie jest liczba calkowita\n");
- i = 0;
- break;
- }
- }
- else if (!isdigit(c) && c != ' ' && c!='\t') {
- printf("Blad - podano znak niedozwolonyxxxx\n");
- i = 0;
- break;
- }
- c = getchar();
- }
- i++;
- skok2:
- if (c == '\n') {
- if (i == 3) {
- printf("Liczby zostaly wpowadzone poprawnie\n");
- exit(0);
- }
- printf("Blad - za malo poprawnych liczb\n");
- i = 0;
- continue;
- }
- continue;
- }
- else if (c == ' ')
- continue;
- else if (c == '\n') {
- printf("Blad - brak liczb\n");
- continue;
- }
- else {
- printf("Blad - podano znak niedozwolony (inny od cyfry lub spacji)\n");
- i = 0;
- continue;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement