Ответить на сообщение
Вернуться к теме
Вы отвечаете на сообщение:
Автор: kandrey (09.10.2009 в 16:03) Задание таково: "Написать программу на языке C++ чересстрочного слияния (т.е. первая строка в выходном файле - это первая строка из первого файла, вторая строка в выходном файле - это первая строка из второго файла, третья строка в выходном файле - вторая строка из первого файла и т.д.) двух текстовых файлов с удалением в каждой строке слов после которых стоит любой знак препинания." вот моя прога
#include <stdio.h> #include <iostream.h> #include <ctype.h> #include <stdlib.h> char* rez_strok_dubl; int ch_str_1= 0; int ch_str_2= 0; int lenf1; int lenf2; void func (char* uk, int* ch_str, char* stroka, int len) { while ((*uk!=10)&&(*ch_str<len-1)) { uk++; (*ch_str)++; } if (!ispunct(*(uk-1))) { do { uk--; (*ch_str)--; } while (!ispunct(*uk)&&(*uk!=10)&&(uk!=stroka)); if (uk!=stroka) { uk++; (* ch_str)++; } while ((*uk!= 10)&&(*ch_str<len- 1)) { *rez_strok_dubl++=*uk++; (*ch_str)++; } *rez_strok_dubl++=*uk++; } uk++; (*ch_str)++; } int main(){ FILE *f1, *f2; if (!(f1= fopen ("D:\\work\\file_1.txt", "rb"))) { cout<<"file_1_ne_otkrit\n"; system ("PAUSE"); exit (1); } if (!(f2= fopen ("D:\\work\\file_2.txt", "rb"))) { cout<< "file_2_ne_otkrit\n"; system ("PAUSE"); exit (1); } fseek (f1, 0, SEEK_END); lenf1=ftell(f1); fseek (f2, 0, SEEK_END); lenf2=ftell(f2); char* stroka_1= (char*) malloc (lenf1) ; char* stroka_2= (char*) malloc (lenf2) ; fseek (f1, 0, SEEK_SET); fseek (f2, 0, SEEK_SET); fread (stroka_1, lenf1, 1, f1); fread (stroka_2, lenf2, 1, f2); fclose (f1); fclose (f2); char* rez_strok= (char*) malloc (lenf1+lenf2) ; rez_strok_dubl= rez_strok; while (ch_str_2<lenf2) { func (&stroka_1[ch_str_1], &ch_str_1, stroka_1, lenf1); func (&stroka_2[ch_str_2], &ch_str_2, stroka_2, lenf2); } FILE* f3; if (!(f3= fopen ("D:\\work\\B.txt", "wb"))) { cout<< "file_3_ne_otkrit\n"; system ("PAUSE"); exit (1); } int i= 0; while (&rez_strok [i]!= rez_strok_dubl) fputc ((unsigned char)rez_strok [i++], f3); fclose (f3); return 0; }
First codex was used for accounting, but with the development of parchment in the III century BC. e., gradually began to displace the papyri. This is already happening in the Christian world. The reasons for the adoption of the manuscript as the main type of books several: it is economical because you can use both sides of the paper, it is easy to hide; It was convenient and accessible. Perhaps the Christian writers used the original purpose, that they were not similar to the pagan texts, which are usually written in the form of scrolls.
At the beginning of XIV century in Western Europe appeared woodcutting (it was developed long before the East). In the matrix of woodcuts depicting Pages cut from a piece of wood. It can be dipped in ink and used to make multiple copies of a page. Books, as well as playing cards and religious pictures, began to produce woodcuts. But the creation of the book was laborious process, since each page had to do his carving. Besides, First codex was used for accounting, but with the development of parchment in the III century BC. e., gradually began to displace the papyri. This is already happening in the Christian world. The reasons for the adoption of the manuscript as the main type of books several: it is economical because you can use both sides of the paper, it is easy to hide; It was convenient and accessible. Perhaps the Christian writers used the original purpose, that they were not similar to the pagan texts, which are usually written in the form of scrolls.
but it was developed In the matrix of woodcuts depicting Pages The reasons for the adoption of the manuscript as the main type of books It can be dipped in ink and as well as playing that they were not But the creation of the book was which are usually written in the form of scrolls. but ¦ ¦ The reasons for the adoption of the manuscript as the main type of books ¦ ¦ that they were not ¦ which are usually written in the form of scrolls.
with the development of parchment in the III century gradually began to displace the
Ваше имя:
Пароль:
Цитировать Используйте тэги для выделения текста: Код: [code][/code] Жирный: [b][/b] Наклонный: [i][/i] URL: [url][/url]
Сообщение:
Прикрепить: