输入多组数据,每一组若先输入数字则再输入一
个字符,输出扩展这个字符,扩展个数为输入的数字,如“3a”
则输出“aaa”;若输入字符则输出该字符,如“ab”输出“ab”;若输
入“#”则表示程序结束。
范例:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char s[20],str[20];
while (1)
{
gets_s(s);
if (strcmp(s, "#") == 0)break;
for (int i = 0; i < strlen(s); i+=2)
{
if (s[i] >= '0'&&s[i] <= '9'&&s[i + 1] >= 'a'&&s[i + 1] <= 'z')
{
for (int j = 0; j < s[i] - '0'; j++)
printf("%c", s[i + 1]);
}
else
printf("%s", s);
}
printf("\n");
}
system("pause");
return 0;
}