请帮助我运行下c++程序,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/07/07 05:58:15
#include <iostream>

using namespace std;

int main ()

{

int i;

int j;

int num;

string sym, symb;

cout << "Enter two characters and an integer: ";

cin>> sym>> symb>> num;

for (i = 1; i <= num; i++)

{

for (j = i; j <= i + num - 1; j++)

{

{

if(j % 2)

cout << sym;

else

cout << symb;

}

}

cout << endl;

}return 0;

}

#include <iostream>
using namespace std;
int main ()
{
int i;
int j;
int num;
string sym, symb; //这里有问题,c++里没有string类型,只有mfc里含有这个类。
cout << "Enter two characters and an integer: ";
cin>> sym>> symb>> num;
for (i = 1; i <= num; i++)
{
for (j = i; j <= i + num - 1; j++)
{
if(j % 2)
cout << sym;
else
cout << symb;
}
cout << endl;
}
return 0;
}

--------------------Configuration: Text6 - Win32 Debug--------------------
Compiling...
Text6.cpp
f:\my vc pro\ÍøÉÏ´ðÒÉ\text6.cpp(25) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no accep