Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<locale.h>
- #include<stdio.h>
- #define _CRT_SECURE_NO_WARNINGS
- #define INPUT "input.txt"
- #define OUTPUT "output.txt"
- using namespace std;
- struct Word
- {
- char ch = 0;
- Word* next;
- };
- struct Line
- {
- int count = 0;
- Word* word;
- Line* next;
- };
- void search(Line* line, int find)
- {
- Word* wordNow;
- wordNow = line->word->next;
- while (wordNow != NULL)
- {
- if (((int(wordNow->ch)) % 2) == find)
- line->count++;
- printf ("%c", wordNow->ch);
- wordNow = wordNow->next;
- }
- printf ("<-","\n");
- printf ("%d \n", line->count);
- }
- void main()
- {
- setlocale(LC_ALL, "Russian");
- char ch = 0;
- int find;
- bool point = false;
- //fstream file;
- //file.open(INPUT);
- FILE *file;
- if (file = fopen("C:\Games\input.txt","r"))
- {
- printf ("Четное или нечетное: ");
- scanf_s("%d ",&find);
- find = find % 2;
- Line lineFirst;
- Line* lineNow;
- lineNow = &lineFirst;
- lineFirst.word = new Word;
- Word* wordNow = lineFirst.word;
- while ((ch != EOF) && (ch != '.'))
- {
- fscanf_s(file, "%c", &ch);
- //printf_s(" 1 %c ", ch);
- if (ch == '.') point = true;
- if ((ch != ' ') && (ch != '.'))
- {
- wordNow->next = new Word;
- wordNow = wordNow->next;
- wordNow->ch = ch;
- }
- else if (wordNow->ch != 0)
- {
- lineNow->next = new Line;
- lineNow = lineNow->next;
- lineNow->word = new Word;
- wordNow->next = NULL;
- wordNow = lineNow->word;
- }
- }
- fclose(file);
- wordNow->next = NULL;
- lineNow->next = NULL;
- }
- else {
- printf ("Input file not found!\n");
- }
- //scanf("%s ",&ch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement