|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 傾小靈 于 2020-11-30 19:00 编辑
- #include <stdio.h>
- #include <string.h>
- int bisearch(int num)
- {
- int j = 0,i =0;
- char array[10];
- scanf("%s",&array);//输入字符串,用for循环把字符串中的空格省略
- for(i; i <= strlen(array) - 1; i++)
- {
- if(array[i] != ' ')//在实际操作中输入空格,但数组array中没有空格' '的存储
- {
- array[j] = array[i];
- j++;
- }
- }
- if(num != strlen(array))
- {
- printf("error");
- return 0;
- }
- }
- int main()
- {
- bisearch(2);
- system("pause");
- return 0;
- }
复制代码
救救孩子吧,谢谢
本帖最后由 jackz007 于 2020-11-30 19:51 编辑
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- char c ;
- for(; (c = getchar()) != '\n' ;) if(c != ' ') putchar(c) ;
- putchar('\n') ;
- system("pause") ;
- }
复制代码
编译、运行实况:
- D:\00.Excise\C>g++ -o x x.c
- D:\00.Excise\C>x
- Hello World !
- HelloWorld!
- 请按任意键继续. . .
- D:\00.Excise\C>
复制代码
|
|