从键盘输入一个字符串,然后按照字符顺序从小到大进行排序,并删除重复的字符。 程序清单:

#include "stdio.h"#include "string.h"void main(){ char ch,a[80],b[80];int i,j,t;scanf("%s",ch);for(i=0;i<strlen(ch)-1;i++)scanf("%c",a[i]);for(i=0;i<strlen(ch)-1;i++)for(j=i+1;j<i;j++)if(a[i]>a[j]) t=a[j],a[j]=a[i],a[i]=t;for(i=0;i<strlen(ch)-1;i++)if(a[i]=a[i+1]) b[i]=a[i];printf("%s",b[i]);}这是我编程的我们学到指针了 但是我没用指针程序错误是error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style castD:C语言文件前期我\ 是是阿萨.cpp(9) : error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style castD:C语言文件前期我\ 是是阿萨.cpp(12) : error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast执行 cl.exe 时出错.不用指针能编程吗这个

#include "stdio.h"void main(){ int n; printf("请输入字符串的字符个数:"); scanf("%d",&n); printf("请输入字符串:"); char *a=new char[n]; scanf("%s",a); for(int i=0;i<n;i++) { char min=a[i]; int sign=i; for(int j=i+1;j<n;j++) { if(a[j]=='
温馨提示:答案为网友推荐,仅供参考
相似回答