[ create a new paste ] login | about

Link: http://codepad.org/CR1izYYy    [ raw code | output | fork ]

C++, pasted on Oct 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <algorithm>
#include <numeric>
#include <locale>

int main()
{
   setlocale(LC_ALL, "");

   char arr[] = "0123xxx##yyy#zzz";
   const size_t N = strlen(arr);

   std::cout << "Сумма кодов: " << std::accumulate(arr, arr+N, 0) << std::endl;
   const size_t signs = std::count(arr, arr+N, '#');
   std::replace(arr, arr+N, '#', 'A');
   std::cout << "Количество #: " << signs << std::endl;
   std::cout << "После преобразования: " << arr << std::endl;

   return 0;
}


Output:
1
2
3
Сумма кодов: 1392
Количество #: 3
После преобразования: 0123xxxAAyyyAzzz


Create a new paste based on this one


Comments: