From c44c157db51004157156300cd8137211c294d59f Mon Sep 17 00:00:00 2001 From: Davide Pollicino Date: Sun, 25 Oct 2020 15:51:08 +0000 Subject: [PATCH] Update process-a-string.cpp --- codechef/process-a-string.cpp | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/codechef/process-a-string.cpp b/codechef/process-a-string.cpp index e69de29..4582e0e 100644 --- a/codechef/process-a-string.cpp +++ b/codechef/process-a-string.cpp @@ -0,0 +1,45 @@ +// https://www.codechef.com/problems/KOL15A +#include + +using namespace std; + + + +int get_sum_digits(string word) +{ + // Case 1 : string is empty + if(word.size() == 0) + return 0; + // Case 2: string is NOT empty + int sum = 0; + for(int i=0; i < word.size(); i++) + { + cout << "sum is: "<> test_cases; + string word; + while(test_cases--) + { + cin >> word; + cout << get_sum_digits(word)<