回复 3楼 pangding
谢谢指点,还想问一下,既然一个程序已经可以运行了,调试又是起什么作用的?另外还有个小问题,今天对照书上的一个程序进行编译时,出现如下提示今This application has requested the
Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.想问下怎么
回事?
#include<iostream>
#include<string>
using std::cout;using std::endl;using std::cin;using std::string;
int main()
{ // say what standard-library name we use
string name;
cout<<"Please enter your name: ";
cin>>name;
const string greeting="hello, "+greeting+" !";
const int pad=2;
const int rows=pad*2+3;
const string::size_type cols=greeting.size()+pad*2+2;
//write a blank line to sepeater input and output
cout<<endl;
// invariant:we have written r rows so far
for(int r=0;r!=rows;++r){
string::size_type c=0;
while(c!=cols){
if(r==pad+1&&c==pad+1){
cout<<greeting;
c+=greeting.size();
}else{
if(r==0||r==rows-1||c==0||c==cols-1)
cout<< "*";
else
cout<< " ";
++c;
}
}
}
return 0;
}