C outputs strings in the order specified by the inputs

Updated on technology 2024-04-01
4 answers
  1. Anonymous users2024-02-07

    #include

    main()

    int x,y,z;

    char str[3][7]=;

    printf("The output order is:");

    scanf("%d %d %d",&x,&y,&z);

    printf("%s %s %s",str[x],str[y],str[z]);

    Multiple variables can be added to the input and output, and strings can also be added to the n of str[n]. Hope!!!

  2. Anonymous users2024-02-06

    Summary. The most commonly used method is the use of pointers, the specific steps are as follows:1

    declare a character pointer variable p and initialize it as the first address of the string; 2.Make the pointer variable q point to the end of the string, i.e., q=p+strlen(p)-1;3.Swaps the characters pointed to by pointers p and q, and moves pointer p backward by one position and pointer q forward by one position; 4.

    Repeat step 3 until p and q point to the same character, completing the reverse order of the string.

    C outputs a string of characters in reverse order.

    Make the pointer variable q point to the end of the string, i.e., q=p+strlen(p)-1;3.Swaps the characters pointed to by pointers p and q, and moves pointer p backward by one position and pointer q forward by one position; 4.Repeat step 3 until p and q point to the same character, completing the reverse order of the string.

    Pro, include include int main() Here is the complete program: include void main( ).

  3. Anonymous users2024-02-05

    The general reverse order uses two while, but not many people use it, giving you three common methods.

    One sets two pointers to point to the head and tail of the string, then swaps the character that the two pointers point to, and moves the pointer to the middle until it crosses.

    char *reverse(char *s) return s ;2. In the recursive way, you need to give a reversed interval and call the method: reverse(s, 0, strlen(s)).

    The string s is reversed between the interval left and right, and the recursive method char *reverse( char *s, int left, int right ) three non-recursive methods, which also specify the reverse order interval, is not fundamentally different from method 1, one uses a pointer, and the other uses a subscript.

    Reverse the order of the string str between the interval left and right char *reverse( char *s, int left, int right ) return s; }

  4. Anonymous users2024-02-04

    Function name: strrev

    Function: String reversal.

    Usage: char *strrev(char *str);

    Example: include

    #include

    int main(void)

Related questions
10 answers2024-04-01

In C, you can't actually get carriage returns with any method (regular library functions). Because the console is after you enter a line and click enter, send the characters other than the enter to the program input cache together, you can only use workarounds, such as getting a line, a character or a number at a time, and setting multiple inputs, then after entering, it will inevitably go into the next input or ** block. >>>More

3 answers2024-04-01

Yan Shu's "Huanxi Sha, a New Song and a Cup of Wine" is a famous article of the Song Dynasty, expounding the philosophy: all the beautiful things that are bound to disappear cannot prevent their disappearance, but there are still beautiful things at the same time as they disappear, and life will not become a void because of the disappearance, but this kind of reappearance is not equal to the original reappearance of beautiful things after all, it is just "déjà vu", and what permeates the sentence is a mixture of nostalgia and melancholy, which seems to be both rushing and deep and graceful life touch.

9 answers2024-04-01

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

11 answers2024-04-01

Valid variable names for the C language:

First, it can only contain numbers, letters, and underscores. >>>More