Patrick on Nostr: #[0] 帮我看看下面这段C++代码有没有问题 #include <iostream> using ...
dave (npub1tsg…htk4) 帮我看看下面这段C++代码有没有问题
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
char sign;
cout << "Please enter two numbers: ";
cin >> num1 >> num2;
cout << "Please enter the sign: ";
cin >> sign;
switch(sign)
{
case '+':
cout << num1 << " + " << num2 << " = " << num1+num2 <<endl;
break;
case '-':
cout << num1 << " - " << num2 << " = " << num1-num2 <<endl;
break;
case '*':
cout << num1 << " * " << num2 << " = " << num1*num2 <<endl;
break;
case '/':
cout << num1 << " / " << num2 << " = " << num1/num2 <<endl;
break;
default:
cout << "Invaid operand";
break;
}
return 0;
}
Published at
2023-02-07 11:32:07Event JSON
{
"id": "4d07b7492f7adc06ed830c9326285756c39032970cabf3833f6169b36b2abf5f",
"pubkey": "c8ae3acd9c976dee5afa104411cae8d6dfffafa592a328fe7f82578a70812302",
"created_at": 1675769527,
"kind": 1,
"tags": [
[
"p",
"5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2"
],
[
"t",
"include"
]
],
"content": "#[0] \n帮我看看下面这段C++代码有没有问题\n#include \u003ciostream\u003e\nusing namespace std; \nint main()\n{\n int num1, num2;\n char sign;\n cout \u003c\u003c \"Please enter two numbers: \";\n cin \u003e\u003e num1 \u003e\u003e num2;\n cout \u003c\u003c \"Please enter the sign: \";\n cin \u003e\u003e sign;\n switch(sign)\n {\n case '+':\n cout \u003c\u003c num1 \u003c\u003c \" + \" \u003c\u003c num2 \u003c\u003c \" = \" \u003c\u003c num1+num2 \u003c\u003cendl;\n break;\n case '-':\n cout \u003c\u003c num1 \u003c\u003c \" - \" \u003c\u003c num2 \u003c\u003c \" = \" \u003c\u003c num1-num2 \u003c\u003cendl;\n break;\n case '*':\n cout \u003c\u003c num1 \u003c\u003c \" * \" \u003c\u003c num2 \u003c\u003c \" = \" \u003c\u003c num1*num2 \u003c\u003cendl;\n break;\n case '/':\n cout \u003c\u003c num1 \u003c\u003c \" / \" \u003c\u003c num2 \u003c\u003c \" = \" \u003c\u003c num1/num2 \u003c\u003cendl;\n break;\n default:\n cout \u003c\u003c \"Invaid operand\";\n break;\n }\n return 0;\n}",
"sig": "401e7e818abf45eeddb6624048a244b4047c101b546f49597ef0b14f80fda538f7795b9d84507e67fd28a60c29af6dedddfa10af525fa8445bf77f1f9f60890e"
}