1 solutions

  • 0
    @ 2025-11-5 15:43:56

    C++ :

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    void swap(char *p,char *q)
    {
    	char str[50];
    	strcpy(str,p);
    	strcpy(p,q);
    	strcpy(q,str);
    }
    int main()
    {
    	char s1[50],s2[50],s3[50];
    	char *p1=s1,*p2=s2,*p3=s3;
    	gets(p1); gets(p2); gets(p3);
    	if (strcmp(p1,p2)>0) swap(p1,p2);
    	if (strcmp(p1,p3)>0) swap(p1,p3);
    	if (strcmp(p2,p3)>0) swap(p2,p3);
    	printf("%s\n%s\n%s\n",p1,p2,p3);
    	return 0;
    }
    

    Pascal :

    var x:string;
        y,z,i,j:integer;
        a:array [1..3] of string;
    begin
      for i:=1 to 3 do readln(a[i]);
      for i:=1 to 3 do
       for j:=1 to 3 do
       if a[i]>a[j] then begin x:=a[i]; a[i]:=a[j]; a[j]:=x; end;
       for i:=3 downto 1 do writeln(a[i]);
        
    end.
    
    • 1

    C语言程序设计教程(第三版)课后习题10.2

    Information

    ID
    17101
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By