int __main(void) { int store [20]; volatile unsigned char r; char text [] = "1234"; char test [] = "hello"; volatile int result = asciiToBCD(0x30); result = asciiToBCD(0x3239); result = BCDToAscii(0x1234); result = BCDToAscii(0x0); r = cipher('A'); r = cipher('Z'); r = ccipher('A', 5); result = bit_reverse(0xAAAA0000); fib(20, store); char_reverse(text, 4); word_reverse(text, 4); word_reverse(test, 5); word_reverse_compiled(text, 4); word_reverse_compiled(test, 5); return 0; }
void main() { char str[100]; int k; printf("Enter a sentence\n"); scanf("%s",str); reverse(str); word_reverse(str, 0); printf("The reverse string is \t %s",str); }
int main() { char buf[BUF]; printf("please intput your favorite string!\n"); gets(buf); printChar(buf); /*a regular sequence*/ printChar(normal_reverse(buf)); // printChar(swap_reverse(buf)); // printChar(XOR_reverse(buf)); printChar(word_reverse(buf)); return 0; }
void str_words_in_rev(char *input, int len) { int i = 0, low = 0, high = -1, spaces[5]; while (i <= len) { if ((input[i] == 32 && input[i - 1] != 32) || input[i] == '\0') { word_reverse(input, low, high);//if conditions are used to know starting and ending index of words low = -1; } else if (input[i] == 32 && input[i + 1] == 32) { low = -1; } else { if (i == 0 && low == 0) { low = 0; } if (low == -1&&input[i]!=32) { low = i; } } high++; i++; } low = 0; high = high - 1; while (high - low>0) { input[low] = input[low] ^ input[high]; input[high] = input[low] ^ input[high]; input[low] = input[low] ^ input[high]; low++; high--; } }
void word_reverse(char *str,int i) { char temp; int t, j; j = i; for (i; str[i] != ' '; i++) { if (str[i] == '\0') break; } t = i + 1; while (j<i) { temp = str[j]; str[j] = str[i - 1]; str[i - 1] = temp; j++; i--; } if (str[t-1] == '\0') return; else word_reverse(str, t); }