示例#1
0
static void ComplexDictionary::build(string name) {
    string buffer;
    while (cin >> buffer) {
        size_t index = -1;
        if (buffer.find("//") != string::npos) {
            if (index = buffer.find("&")) {
                reversal(buffer);
            }
            else if (index = buffer.find("[")) {
                size_t endIndex = buffer.find("]");
                insertEach(buffer, index, endIndex);
            }
            else if (index = buffer.find("?")) {
                optional(buffer, index);
            }
            else if (index = buffer.find("!")) {
                swap(buffer, index);
            }
            else
                words.push_back(buffer);
        }
    }

    reverse(words.begin(), words.end());
}
示例#2
0
文件: hello52.c 项目: Anish122/Codes
void main(){
    int length;
    char arr[100];
printf("enter the string:\n");
gets(arr);
reversal(arr);
puts(arr);
}
int reversal(char *p, char *q)
{
	int shift;

	if (*p == '\0' || *p == '\n')
		return 0;
	else
		shift = reversal(p+1,q);

	*(q + shift) = *p;

	return shift + 1;
}	
int main(int argc,char *argv[])
{
	char *temp,*temp2;

	if (argc != 3)
	{
		printf("Error: Incorrect number of arguments.\n");
		return 0;
	}
	
	infp = fopen(argv[1],"r");
	outfp = fopen(argv[2],"w");

	if (infp == NULL)
	{
		printf("Error: %s does not exist.\n",argv[1]);
		return 0;
	}

	while (1)
	{
		temp = (char *) calloc ((1+LINE_SIZE), sizeof(char));

		if (fgets(temp,LINE_SIZE,infp) == NULL)
			break;

		temp2 = (char *) calloc ((1+LINE_SIZE), sizeof(char));

		reversal(&temp[0],&temp2[0]);
	
		if (temp[0] != '\n')
		{
			fputs(temp2,outfp);
			fputs("\n",outfp);
		}

		free(temp);	
		free(temp2);
	}

	fclose(infp);
	fclose(outfp);


	return 0;
}
示例#5
0
int main(){
    char str[10] = "hello";
    hello_world();

    n_hello_world(5);

    printf("len=%d\n", w_strlen("hello world"));

    change_str_test();

    printf("222 %s\n", reversal(str));

    concat_test();

    customer_manager();

    return 0;
}