#include <stdio.h>
int main() {
char ch;
int checksum = 0;
int wordChecksum = 0;
int inWord = 0;
if (ch == ' ' || ch == '\n' || ch == '\t') {
if (inWord) {
printf("Kontrolnya summa vseh slov: %d\n", wordChecksum
); checksum += wordChecksum;
wordChecksum = 0;
inWord = 0;
}
} else {
wordChecksum += (char)ch; // Суммируем ASCII значения символов
inWord = 1;
}
}
// Обработка последнего слова, если ввод не закончился пробелом
if (inWord) {
printf("Kontrolnaya summa: %d\n", wordChecksum
); // Выводим сумму слова checksum += wordChecksum;
}
printf("Obshaya summa: %d\n", checksum
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGNoYXIgY2g7CiAgICBpbnQgY2hlY2tzdW0gPSAwOwogICAgaW50IHdvcmRDaGVja3N1bSA9IDA7CiAgICBpbnQgaW5Xb3JkID0gMDsKCiAgICB3aGlsZSAoKGNoID0gZ2V0Y2hhcigpKSAhPSBFT0YpIHsKICAgICAgICBpZiAoY2ggPT0gJyAnIHx8IGNoID09ICdcbicgfHwgY2ggPT0gJ1x0JykgewogICAgICAgICAgICBpZiAoaW5Xb3JkKSB7CiAgICAgICAgICAgICAgICBwcmludGYoIktvbnRyb2xueWEgc3VtbWEgdnNlaCBzbG92OiAlZFxuIiwgd29yZENoZWNrc3VtKTsKICAgICAgICAgICAgICAgIGNoZWNrc3VtICs9IHdvcmRDaGVja3N1bTsKICAgICAgICAgICAgICAgIHdvcmRDaGVja3N1bSA9IDA7CiAgICAgICAgICAgICAgICBpbldvcmQgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgd29yZENoZWNrc3VtICs9IChjaGFyKWNoOyAvLyDQodGD0LzQvNC40YDRg9C10LwgQVNDSUkg0LfQvdCw0YfQtdC90LjRjyDRgdC40LzQstC+0LvQvtCyCiAgICAgICAgICAgIGluV29yZCA9IDE7CiAgICAgICAgfQogICAgfQoKICAgIC8vINCe0LHRgNCw0LHQvtGC0LrQsCDQv9C+0YHQu9C10LTQvdC10LPQviDRgdC70L7QstCwLCDQtdGB0LvQuCDQstCy0L7QtCDQvdC1INC30LDQutC+0L3Rh9C40LvRgdGPINC/0YDQvtCx0LXQu9C+0LwKICAgIGlmIChpbldvcmQpIHsKICAgICAgICBwcmludGYoIktvbnRyb2xuYXlhIHN1bW1hOiAlZFxuIiwgd29yZENoZWNrc3VtKTsgLy8g0JLRi9Cy0L7QtNC40Lwg0YHRg9C80LzRgyDRgdC70L7QstCwCiAgICAgICAgY2hlY2tzdW0gKz0gd29yZENoZWNrc3VtOwogICAgfQoKICAgIHByaW50ZigiT2JzaGF5YSBzdW1tYTogJWRcbiIsIGNoZWNrc3VtKTsKCiAgICByZXR1cm4gMDsKfQ==