#include <stdio.h>
int main() {
char ch;
int checksum = 0;
int wordChecksum = 0;
int inWord = 0;
printf("Vvedita tekst (Ctrl+D dlya zavershite):\n");
if (ch == ' ' || ch == '\n' || ch == '\t') {
if (inWord) {
printf("Kontrolnya summa vseh slov: %lu\n", wordChecksum
); checksum += wordChecksum;
wordChecksum = 0;
inWord = 0;
}
} else {
wordChecksum += (unsigned char)ch; // Суммируем ASCII значения символов
inWord = 1;
}
}
// Обработка последнего слова, если ввод не закончился пробелом
if (inWord) {
printf("Kontrolnaya summa: %lu\n", wordChecksum
); checksum += wordChecksum;
}
printf("Obshaya summa: %lu\n", checksum
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGNoYXIgY2g7CiAgICBpbnQgY2hlY2tzdW0gPSAwOwogICAgaW50IHdvcmRDaGVja3N1bSA9IDA7CiAgICBpbnQgaW5Xb3JkID0gMDsKCiAgICBwcmludGYoIlZ2ZWRpdGEgdGVrc3QgKEN0cmwrRCBkbHlhIHphdmVyc2hpdGUpOlxuIik7CgogICAgd2hpbGUgKChjaCA9IGdldGNoYXIoKSkgIT0gRU9GKSB7CiAgICAgICAgaWYgKGNoID09ICcgJyB8fCBjaCA9PSAnXG4nIHx8IGNoID09ICdcdCcpIHsKICAgICAgICAgICAgaWYgKGluV29yZCkgewogICAgICAgICAgICAgICAgcHJpbnRmKCJLb250cm9sbnlhIHN1bW1hIHZzZWggc2xvdjogJWx1XG4iLCB3b3JkQ2hlY2tzdW0pOwogICAgICAgICAgICAgICAgY2hlY2tzdW0gKz0gd29yZENoZWNrc3VtOwogICAgICAgICAgICAgICAgd29yZENoZWNrc3VtID0gMDsKICAgICAgICAgICAgICAgIGluV29yZCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB3b3JkQ2hlY2tzdW0gKz0gKHVuc2lnbmVkIGNoYXIpY2g7IC8vINCh0YPQvNC80LjRgNGD0LXQvCBBU0NJSSDQt9C90LDRh9C10L3QuNGPINGB0LjQvNCy0L7Qu9C+0LIKICAgICAgICAgICAgaW5Xb3JkID0gMTsKICAgICAgICB9CiAgICB9CgogICAgLy8g0J7QsdGA0LDQsdC+0YLQutCwINC/0L7RgdC70LXQtNC90LXQs9C+INGB0LvQvtCy0LAsINC10YHQu9C4INCy0LLQvtC0INC90LUg0LfQsNC60L7QvdGH0LjQu9GB0Y8g0L/RgNC+0LHQtdC70L7QvAogICAgaWYgKGluV29yZCkgewogICAgICAgIHByaW50ZigiS29udHJvbG5heWEgc3VtbWE6ICVsdVxuIiwgd29yZENoZWNrc3VtKTsKICAgICAgICBjaGVja3N1bSArPSB3b3JkQ2hlY2tzdW07CiAgICB9CgogICAgcHJpbnRmKCJPYnNoYXlhIHN1bW1hOiAlbHVcbiIsIGNoZWNrc3VtKTsKCiAgICByZXR1cm4gMDsKfQ==