Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Visual C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 17.06.2011, 00:12   #1
Leoweb
 
Регистрация: 17.06.2011
Сообщений: 3
По умолчанию Правила обработки документов.

Source Code Change Sets
Description
Create a console program that can perform the following operations:
• generate a change set file CAB for any given pair of text files (TA, TB)
• apply a given change set file CAB to an input file TX and produce the target file TY.
NOTE: when applied to the input file TA the change set file CAB must produce the original file TB
Detailed specification
• Files TA and TB are plain ANSI charset text files (ordered collection of lines delimited by ‘\n’ character or ‘\r\n’ character combination).
• The change set file CAB should contain human readable instructions to convert file TA into file TB. It is part of your work to design your own specification of the conversion instructions and change set file format.
• The conversion instructions should work with whole lines (do not refer to words or symbols inside a line). Lines that differ at least in one character should be considered different (treat differences in whitespace as significant).
• The conversion instructions must be bound to the surrounding lines context (SLC). It is not allowed to bind conversion instructions to absolute or relative line numbers.
• Each SLC in CAB must identify the lines being added, deleted, or modified uniquely in the scope of change set CAB if it is applied to the source file TA. In other words, applying the change set instructions from CAB to the original file TA must never be ambiguous.
• The program must allow applying the change set file to any text file if the contents of the text file are compatible with the contexts found in the change set file. Otherwise the error description should be printed out to the console. The two basic types of errors are: “required context not found” and “change set applying is ambiguous”.
Program name
Executable file name for the program should be “sccs.exe”.
Program arguments
Use case 1
sccs.exe input_file_1 input_file_2 changeset_file
Analyze input files input_file_1 and input_file_2, generate instructions to convert input_file_1 to input_file_2, and output the conversion instructions into the changeset_file.
Use case 2
sccs.exe input_file output_file changeset_file /apply
Apply the changeset_file to the input_file and output the results to the output_file.
Example
Creating a change set: sccs.exe 1.txt 2.txt C12.txt
Input file 1.txt

A
B
C
E
F
G
A
B
C
E Input file 2.txt

A
C
D
F
G
H
B
C
D
E Change set file C12.txt

find
>B
>C
>E
>F
replace with
>C
>D
>F

find
>G
>A
>B
>C
replace with
>G
>H
>B
>C
>D
NOTE: The format and contents of C12.txt file is not enforced in this task. It can be chosen to fit your algorithm, as long as it stays a human readable text file.
Applying the change set to another file: sccs.exe 1a.txt C12.txt 2a.txt /apply
Input file 1a.txt

K
A
B
C
E
F
K
G
A
B
C
E
L Output file 2a.txt

K
A
C
D
F
K
G
H
B
C
D
E
L
NOTE: given the input files 1.txt, 2.txt and 1a.txt your program should produce the same 2a.txt.


Перевод задания не стал давать т.к. в оригинале на мой взгляд понятнее. Зараннее спс. P.S. тоже самое в ворде прикреплено но с табличками примера поудобнее.
Вложения
Тип файла: doc Source Code Change Sets.doc (42.0 Кб, 8 просмотров)
Leoweb вне форума Ответить с цитированием
Старый 17.06.2011, 00:40   #2
Scaevola
Пользователь
 
Аватар для Scaevola
 
Регистрация: 08.06.2011
Сообщений: 25
По умолчанию

Ну ты даешь!!Без наработак и еще на английском!
Scaevola вне форума Ответить с цитированием
Старый 17.06.2011, 01:17   #3
Leoweb
 
Регистрация: 17.06.2011
Сообщений: 3
По умолчанию ...

Да мне бы хотя бы идею дельного алгоритма...)
Leoweb вне форума Ответить с цитированием
Старый 17.06.2011, 16:58   #4
Rififi
Старожил
 
Регистрация: 19.08.2009
Сообщений: 2,119
По умолчанию

Leoweb

по первой части задания - http://ru.wikipedia.org/wiki/Diff
по второй - http://ru.wikipedia.org/wiki/Patch_%28UNIX%29
Rififi вне форума Ответить с цитированием
Старый 20.06.2011, 00:10   #5
Leoweb
 
Регистрация: 17.06.2011
Сообщений: 3
По умолчанию спс конечно

Но мб будут идеи в коде реализованные?)
Каркас вот написал и начало примерное

// kursovaya.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <locale.h> //заголовочный файл, который используется для локализации
#include <conio.h>
using namespace std;


char* name[100];
string str1[100];
string str2[100];
string str3[100];
int i;
bool say;
void openfile (string * str, char * name)
{
ifstream infile (name);
i=0;
while (!infile.eof())
{
getline(infile, str[i]);
cout << (str[i]) << endl ;
i++;
}
}

void chek (string * str1, string * str2, bool * say)
{

if (str1==str2) {*say = true; }
else {*say=false;}
}

void dopravilo (string * str1, string * str2, string * str3)
{
i=0;say=true;
while (i<99)
{
chek (&str1[i], &str2[i], &say);
if (say==true)
{
str1[i]=str3[i];
}
/*else
{
// chek(&str1[i],&str2[i+1],&say); if (say == true) {}
}*/
i++;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(0, "Rus" ); //Необходимо что бы отображать символы кирилицы
openfile(str1, "testin.txt");
i=0;
while (i<99)
{
cout << (str1[i]);
i++;
}
cout << endl;
i=0;
cout << i;
openfile(str2, "testin1.txt");
i=0;
cout << i;
while (i<99)
{
cout << str2[i];
i++;
}
cout << (str2[2]);


dopravilo(str1,str2,str3);
i=0;
while (i<99)
{
cout << str3[i]<<endl;
i++;
}

int a;
cin >> a;


}
Leoweb вне форума Ответить с цитированием
Старый 20.06.2011, 23:09   #6
Rififi
Старожил
 
Регистрация: 19.08.2009
Сообщений: 2,119
По умолчанию

Leoweb

Но мб будут идеи в коде реализованные?)

идеи ты можешь украсть посмотреть сам.

гоогле "diff sources"
гоогле "patch sources"
Rififi вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Продукционные правила Vasek_ Microsoft Office Access 13 06.06.2010 23:03
Правила языков програмирования Nadushka Помощь студентам 9 13.01.2010 12:38
Правила разделов/главные правила Alex Cones О форуме и сайтах клуба 1 30.09.2009 17:49
Правила форума Alar О форуме и сайтах клуба 3 13.08.2008 16:11