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

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

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

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

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

Ответ
 
Опции темы Поиск в этой теме
Старый 30.03.2011, 23:18   #1
SKyzZz
Пользователь
 
Регистрация: 14.02.2011
Сообщений: 43
По умолчанию Это просто смешно ()

Кароче вот прога написана врод верно, но вот ругается на эти вещи
10 MVS С++ 2010

После запкска не создает файл 2.txt, когда открваешь и редактишь 1, я уже масу способов перепробовал*

а задание простое: стирает пробелы в конце строчек
каждое предложение должно начинаться с заглавной буквы; исправить нажатие cAPSLOCK и ДВе заглавные; "цитаты заменить на transliteraciu". Результат сохранить в новом файле. Имена входного и выходного файлов спросить у пользователя.

#include<iostream>
#include<clocale> // library for localization

using namespace std;

int main()
{
setlocale(LC_CTYPE, ""); // russian language

FILE *f_in, *f_out; // input and utput files
char filename_in[100], filename_out[100]; // files name

cout<<"Input name of the file to convert ";
cin>>filename_in;
cout<<"Input name of the file to result ";
cin>>filename_out;
char text[200000], words[10000][20]; // arrays for text and words

int i = 0, ch, b; // i - standard counter, ch - for read chars

f_in = fopen(filename_in, "r"); // read source file

if ( f_in != NULL )
{
do
{
ch = fgetc(f_in);
if (ch != EOF)
text[i] = char(ch);
else text[i] = '\0'; // end of file = end of string
i++;
}

while ( ch != EOF );
text[i-1] = ' ' ;
text[i] = '\0' ;
fclose(f_in);
cout << "\nFile open succesful\n";
}
else cout << "\nError of file read\n";

i=0;
int letters = 0, word_num = 0, symb_in_word = 0;

char cyrillic[64] = { 'а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я',
'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'};
char roman[64] = { 'a', 'b', 'v', 'g', 'd', 'e', 'g', 'z', 'i', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'y', 'f', 'h', 'c', '4', 'w', 'w', '*', 'y', '\'', 'a', 'u', '9',
'A', 'B', 'V', 'G', 'D', 'E', 'G', 'Z', 'I', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'Y', 'F', 'H', 'C', '4', 'W', 'W', '*', 'Y', '\'', 'A', 'U', '9' };




while ( text[i] != '\0')
{
letters++; // number of letters in current word
if ( (text[i] == ' ' && text[i+1] != ' ') || (text[i] == 10 && text[i+1] != 10) ) // the symbol is space, the next - another
{ // or end of the string -//-
for (symb_in_word = 0; symb_in_word < letters; symb_in_word++)
{
words[word_num][symb_in_word] = text[i-letters+symb_in_word+1];
if (words[word_num][symb_in_word] == ' ') words[word_num][symb_in_word] = '\0'; // if space - end of the string
if (words[word_num][symb_in_word] == 10) // if new line - save and add end of the string
{
words[word_num][symb_in_word+1] = '\0';
break;
}
}
word_num ++; // number of words in the text
symb_in_word = 0; // number of letters in the word, inc
letters = 0; // -//-, dec
}
i++; // number of the symbols in the text
}
for (i; i>=0; i--)
text[i] = '\0'; // array is empty

i = 0;
int f[1000] = { 0 } ;
for (int v = 0; v < word_num; v++) // cattering of words in the array
{
i = 0;
while ( words[v][i] != '\0' )
{
if ( words[v][i] >= -32 && words[v][i] <= -1 && words[v][i+1] >= -64 && words[v][i+1] <= -33 )
words[v][i+1] = words[v][i+1] ^ 32; // Caps Lock
if ( words[v][i] >= -64 && words[v][i] <= -33 && words[v][i+1] >= -64 && words[v][i+1] <= -33 )
words[v][i+1] = words[v][i+1] ^ 32; // the first and the second uppercase letters
i++;
}
strcat(text, words[v]);
strcat(text, " ");
}

i=0;
while ( text[i] != '\0')
{
if ( text[i] == '.' || text[i] == '!' || text[i] == '?' )
for (int ii = i+1; ii< i+100; ii ++)
if (text[ii] != ' ' && text[ii] >= 'а' && text[ii] <= 'я' )
{ text[ii] = text[ii] ^ 32; break; }
// if end of the sentence - letter uppercase
i++;
}
i = 0;




while ( text[i] != '\0' )
{
b = i + 1;
if ( text[i] == '\"' )
while ( text[b] != '\"')
{
for (int g = 0; g < 64; g++)
if ( text[b] == cyrillic[g] ) { text[b] = roman[g]; break; } // quotes
b++;
i = b + 2;
}
i++;
}

f_out = fopen(filename_out, "w");
fputs(text, f_out); // write in the new file
fclose(f_out);

return 0;
}
SKyzZz вне форума Ответить с цитированием
Ответ


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



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Pascal ABC - это просто головоломка! Mr_Liahkim Фриланс 9 03.02.2010 19:22
Это просто закладка — чтоб не потеряться Sasha_Smirnov Microsoft Office Word 2 05.02.2009 19:19