小号一个字符串,逆序输出,其中(),[],{},不变:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char* array(char * src)
{
char a;
int n=strlen(src);
int m=n-1;
for(int i=n-1;i>=0;i--)
{
if(src[i]!='('&&src[i]!='('&&src[i]!='['&&src[i]!='{'&&src[i]!=')'&&src[i]!=']'&&src[i]!='}')
{
printf("%c",src[i]);
}
if(src[i]=='(') printf(")");
if(src[i]=='[') printf("]");
if(src[i]=='{') printf("}");
if(src[i]==')') printf("(");
if(src[i]==']') printf("[");
if(src[i]=='}') printf("{");
}
return src;
}
int main(void)
{
char s[100];
gets(s);
array(s);
}