#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("Контрольная сумма всех слов: %d\n", wordChecksum
); checksum += wordChecksum;
wordChecksum = 0;
inWord = 0;
}
} else {
wordChecksum += (char)ch; // Суммируем ASCII значения символов
inWord = 1;
}
}
// Обработка последнего слова, если ввод не закончился пробелом
if (inWord) {
printf("Контрольная сумма: %d\n", wordChecksum
); // Выводим сумму слова checksum += wordChecksum;
}
printf("Общая сумма: %d\n", checksum
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGNoYXIgY2g7CiAgICBpbnQgY2hlY2tzdW0gPSAwOwogICAgaW50IHdvcmRDaGVja3N1bSA9IDA7CiAgICBpbnQgaW5Xb3JkID0gMDsKCiAgICB3aGlsZSAoKGNoID0gZ2V0Y2hhcigpKSAhPSBFT0YpIHsKICAgICAgICBpZiAoY2ggPT0gJyAnIHx8IGNoID09ICdcbicgfHwgY2ggPT0gJ1x0JykgewogICAgICAgICAgICBpZiAoaW5Xb3JkKSB7CiAgICAgICAgICAgICAgICBwcmludGYoItCa0L7QvdGC0YDQvtC70YzQvdCw0Y8g0YHRg9C80LzQsCDQstGB0LXRhSDRgdC70L7QsjogJWRcbiIsIHdvcmRDaGVja3N1bSk7CiAgICAgICAgICAgICAgICBjaGVja3N1bSArPSB3b3JkQ2hlY2tzdW07CiAgICAgICAgICAgICAgICB3b3JkQ2hlY2tzdW0gPSAwOwogICAgICAgICAgICAgICAgaW5Xb3JkID0gMDsKICAgICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHdvcmRDaGVja3N1bSArPSAoY2hhciljaDsgLy8g0KHRg9C80LzQuNGA0YPQtdC8IEFTQ0lJINC30L3QsNGH0LXQvdC40Y8g0YHQuNC80LLQvtC70L7QsgogICAgICAgICAgICBpbldvcmQgPSAxOwogICAgICAgIH0KIC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