新人求教啊
输入一负数,求其平方,要求输出时需要把负数用括号括起来,即输出显示为(-5)*(-5)=25类型的,不知道怎么弄啊
#include <iostream>
using namespace std;
int main(){
int num;
cout<<"Enter an integer: ";
cin>>num;
if(num < 0){
cout<<"("<<num<<") * ("<<num<<") = "<<(num*num)<<endl;
}
else
cout<<num<<" * "<<num<<" = "<<(num*num)<<endl;
system("PAUSE");
return 0;
}
你说的是 这样吗?