首页 >>  正文

字符串排序c语言pta

来源:baiyundou.net   日期:2024-09-22

利颖果2493c语言编程 输入50个字符,按从大到小排序输出 -
缪沈古17683788768 ______ 输入一行字符串,排序前50个,#include<stdio.h>#include<string.h> int main() { char c; int i,j; char buf[50],temp; printf("input 50 numbers\n"); for(i=0;i<50;i++) { if((c=getchar())==EOF) { printf("input err\n"); return -1; } buf[i]=c; } for(i=0;i<49;i++) {...

利颖果2493C语言编程题,输入5个字符串,然后排序 -
缪沈古17683788768 ______ #include#include int main() { char str[5][80]; char temp[80]; int i,j; printf("Please input 5 strings:\n"); for (i=0;i { gets(str[i]); } for (i=0;i { for (j=i+1;j { if (strcmp(str[i],str[j])>0) { strcpy(temp,str[i]); strcpy(str[i],str[j]); strcpy(str[j],temp); } } } printf("The strings:...

利颖果2493C语言逆序排列字符串 -
缪沈古17683788768 ______ 楼主你好 具体代码如下: #include<stdio.h> #include<string.h> int main() { char *p; char c[20]; printf("Enter a string:"); scanf("%s",c); p=c+strlen(c)-1; while(p>=c) printf("%c",*(p--)); printf("\n"); } 希望能帮助你哈

利颖果2493C语言花式排序之字符串怎么写? -
缪沈古17683788768 ______ #include<stdio.h> void main() { int i,j,n,n1,n2; char s[256],c; scanf("%s",s); n=0; while ( s[n]!=0 ) n++; n1=n/2; n2=n-n1; for ( i=0;i<n1-1;i++ ) for ( j=i+1;j<n1;j++ ) if ( s[i*2+1]<s[j*2+1] ) { c=s[i*2+1];s[i*2+1]=s[j*2+1];s[j*2+1]=c; } for ( i=0;i<n2-1;i++ ) ...

利颖果2493C语言去掉重复字符再排序 -
缪沈古17683788768 ______ char a[30] = "qweasdzxcvbnhbgfvredcxswqazx"; for (int i = 0; i < 30; i++) { printf("%c",a[i]); for (int j = 0; j < i; j++) { if (a[i] == a[j]) { a[i] = '0'; } } }printf("\n"); for (int i = 0; i< 30; i++) { if (a[i] != '0') { printf("%c",a[i]); } } 用两个for循环,将字符串...

利颖果2493C语言中如何用冒泡法排列字符串 -
缪沈古17683788768 ______ /* please enter the 1 string : Visual C++ please enter the 2 string : Windows please enter the 3 string : SAMC please enter the 4 string : Primer Plus C++ please enter the 5 string : Stephen Prata 排序前 : Visual C++ Windows SAMC Primer Plus C...

利颖果2493c语言 向字符串中插入字符并排序 -
缪沈古17683788768 ______ #include "stdio.h" #include "string.h" void main() { char s[80];...

利颖果2493C语言字符串排序,不用指针 按照从小到大排序 -
缪沈古17683788768 ______ 这个可以把字符串等效为一个数, 利用冒泡排序, 它们的思想是一样的, 也用两个循环

利颖果2493C语言:一个字符串(空格和字符)按ASCII递增排序
缪沈古17683788768 ______ #include &lt;stdio.h&gt; char* fun(char *s) //直接在原串修改,不能用常量串const char*做参数 { char s1[256] = {0}; //包括扩展的ASCII码,最多不超过256个 char *p = s; while(*p) s1[*p++] = 1; //以ASCII码做下标,自动去重复 s1[' '] = 0; //删除空...

利颖果2493c语言: 输入10个字符串,用选择排序法对十个字符串按大到小排序并输出 -
缪沈古17683788768 ______ #include<conio.h> #include<stdio.h> #include<stdlib.h> #define N 10/* 设定要输入的字符串个数,可更改 */ int cmp(char *p1,char *p2) /* 字符串比较函数 */ {int i=0; while (*(p1+i)==*(p2+i)) if (*(p1+i++)=='\0') return 0; /* 这里是先判断*(p1+i)=='\0...

(编辑:自媒体)
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图 @ 白云都 2024