世界十大足球巨星:C++编程,将字符串“Hello,C++!”赋给一个字符数组,然后从第一个字母开始间隔地输出该串

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/04 21:44:39
3ks

#include <string.h>

main()
{
char s[81];
int i,len;

strcpy(s,"Hello,C++!");
len = strlen(s);
for(i=0;i<len;i+=2)
putchar(s[i]);
return 0;
}

#include <iostream.h>
int main(){
char s[]="Hello,C++!";
char *p=s;
for(;*p!='\0';cout<<*p,p+=2);
}

//我们要向 Von Neumann 前辈学习!!

#include <IOstream.H>

int main(void)
{
std::string s("Hello,C++!");
for(int i = 0 ; s[i] != '\0' ; i += 2)
cout << s[i];

system("PaUSe");
return 0;
}