#include
#include
#include
using namespace std;
void main()
{
for(int i = 0; i < 10; i++)
{
for(int x = 0; x <10 - i; x++)
{
printf(" ");
}
for(int j = 0; j < 2 * i + 1; j++)
{
printf("*");
}
printf("\n");
}
string name ;
name="hello world!";
printf("%s\n",name);
}
首先丢了using namespace std;这条语句,程序会报错。其次应该是#include
改为:
#include
using namespace std;
最后
printf(name);
改成下面这个:
printf(name.c_str());
那个里面定义好像是用char name[]="hello world!";printf("%s\n",name);这样就行了