1.急求VC源代码
急求VC源代码
(1)
#include<iostream>
using namespace std;
int main()
{
float num1,应用源码重庆溯源码燕窝品牌哪个好num2;
char ch;
begin:
cout<<"请输入第1个数:\n";
cin>>num1;
cout<<"请输入运算符:\n";
cin>>ch;
cout<<"请输入第2个数:\n";
cin>>num2;
switch(ch)
{
case '+':
cout<<"结果:"<<num1+num2<<endl;
break;
case '-':
cout<<"结果:"<<num1-num2<<endl;
break;
case '*':
cout<<"结果:"<<num1*num2<<endl;
break;
case '/':
if(int(num2)!=0)
{
cout<<"结果:"<<num1/num2<<endl;
}
else
{
cout<<"除数不能为0,请重新输入.\n";
goto begin;
}
break;
default:
cout<<"你输入的运算符错误,请重新输入.\n";
goto begin;
}
getchar();
return 0;
}
(2)
#include <iostream>
#include<string>
using namespace std;
int main()
{
char num1[];
char num2[];
char ch;
int n=0;
int i=0;
float count=0;
string inStr;
begin:
cout<<"请输入:";
cin>>inStr;
memset(num1,0,);
memset(num2,0,);
for(i=0; inStr[i]!='\0'; i++)
{
if(inStr[i]=='+' ||inStr[i]=='-' ||inStr[i]=='*' ||inStr[i]=='/' )
{
break;
}
else
{
num1[i]=inStr[i];
}
}
ch=inStr[i];
i++;
for(; inStr[i]!='\0'; i++)
{
if(inStr[i]=='+' ||inStr[i]=='-' ||inStr[i]=='*' ||inStr[i]=='/' )
{
break;
}
else
{
num2[n]=inStr[i];
n++;
}
}
switch(ch)
{
case '+':
count=float(atoi(num1))+float(atoi(num2));
break;
case '-':
count=float(atoi(num1))-float(atoi(num2));
break;
case '*':
count=float(atoi(num1))*float(atoi(num2));
break;
case '/':
if(atoi(num2)!=0)
{
count=float(atoi(num1))/float(atoi(num2));
}
else
{
cout<<"除数不能为0"<<endl;
goto begin;
}
break;
}
cout<<"结果是:"<<count<<endl;
}
祝你好运了!!!!!!!!!!!!!
2024-12-24 09:41
2024-12-24 08:57
2024-12-24 08:51
2024-12-24 08:43
2024-12-24 08:39
2024-12-24 08:10