华为机试题:将字符串间隔输出

来源:互联网 发布:红点软件 编辑:程序博客网 时间:2024/05/07 12:22
/*编写一个程序实现功能:将字符串"Computer Secience"赋给一个字符数组,然后从第一个字母开始间隔的输出该串,用指针完成。 */
#include <stdio.h>#include <string.h>#include <iostream.h>int main(){char s[] = "Computer Secience";char *P;P = s;while(*P !=NULL ){cout<<*P++;*P++;if( *P ==' '){*P++;}}cout<<endl;return 0;}