#include <iostream>
int AveChar(char str[]){//not work for EBCDIC.
unsigned int Add = 0;
std::size_t Idx = 0;
while (str[Idx] != '\0') Add += str[Idx++];
return Add / Idx;
}
int main(){
char str[] = "BASIC";
char C = (char)AveChar(str);
std::cout << str << " -> " << C << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IEF2ZUNoYXIoY2hhciBzdHJbXSl7Ly9ub3Qgd29yayBmb3IgRUJDRElDLgoJdW5zaWduZWQgaW50IEFkZCA9IDA7CglzdGQ6OnNpemVfdCBJZHggPSAwOwoKCXdoaWxlIChzdHJbSWR4XSAhPSAnXDAnKSBBZGQgKz0gc3RyW0lkeCsrXTsKCglyZXR1cm4gQWRkIC8gSWR4Owp9CgppbnQgbWFpbigpewoKCWNoYXIgc3RyW10gPSAiQkFTSUMiOwoKCWNoYXIgQyA9IChjaGFyKUF2ZUNoYXIoc3RyKTsKCglzdGQ6OmNvdXQgPDwgc3RyIDw8ICIgLT4gIiA8PCBDIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKCn0=