更新时间2019-06-22 10:34:26
头文件:
#include<bits/stdc++.h>
#define A INT_MAX
#define B INT_MIN
namespace fun
{
int i,t;
int jiecheng(int a,int b){//½×³Ëº¯ÊýÉùÃ÷
int i,sum=1;
for(i=a;i<=b;i++)
{
sum=sum*i;
}
return sum;
}
int zdgys(int a,int b){//×î´ó¹«ÒòÊýº¯ÊýÉùÃ÷
if(a<b)
{
t=a;
a=b;
b=t;
}
for(i=a;i>=1;i--)
{
if(a%i==0&&b%i==0)
{
return i;
break;
}
}
}
int zxgbs(int a,int b){//×îС¹«±¶Êýº¯ÊýÉùÃ÷
if(a<b)
{
t=a;
a=b;
b=t;
}
for(i=a;i>0-10e10;i++)
{
if(i%a==0&&i%b==0)
{
return i;
break;
}
}
}
double pingjunshu(int a,int b){//ƽ¾ùÊýº¯ÊýÉùÃ÷
double c=(a+b)/2.0;
return c;
}
}
源文件:
#include<bits/stdc++.h>
#include"4.cpp"
int main()
{
std::cout<<"ÌØÊâ˵Ã÷: 1¡¢½×³Ë·ûºÅΪ! 2¡¢×î´ó¹«ÒòÊý·ûºÅΪ# 3¡¢×îС¹«±¶Êý·ûºÅΪ@ 4¡¢ÊäÈë0 c 0Çå³ý¼ÆËãºÛ¼£ 5¡¢´Î·½¸ù·ûºÅΪ$ 6¡¢²ÎÓë¼ÆËãµÄ×î´óֵΪ"<<A<<" "<<"7¡¢²ÎÓë¼ÆËãµÄ×îСֵΪ"<<B<<" "<<"9¡¢Æ½¾ùÊý·ûºÅΪ& a";
E:
while(1)
{
bool d;
char ch;
int b,c;
std::cin>>b>>ch>>c;
if(ch!='c'&&ch!='+'&&ch!='-'&&ch!='/'&&ch!='*'&&ch!='!'&&ch!='#'&&ch!='@'&&ch!='$'&&ch!='^'&&ch!='&')
std::cout<<"[Error] "<<ch<<"²»ÊǼÆËãÆ÷¹æ¶¨µÄÔËËã·ûºÅ a";
for(int i=0;i<=10;i++)
if(c==i&&b==i)
goto R;
if(isalnum(b)==0||isalnum(c)==0)
{
continue
goto E;
}
R:
if(ch=='c')
{
system("cls");
std::cout<<"ÌØÊâ˵Ã÷: 1¡¢½×³Ë·ûºÅΪ! 2¡¢×î´ó¹«ÒòÊý·ûºÅΪ# 3¡¢×îС¹«±¶Êý·ûºÅΪ@ 4¡¢ÊäÈë0 c 0Çå³ý¼ÆËãºÛ¼£ 5¡¢´Î·½¸ù·ûºÅΪ$ a";
}
if(ch=='+')
std::cout<<b<<" + "<<c<<"="<<b+c<<" a";
if(ch=='-')
std::cout<<b<<" - "<<c<<"="<<b-c<<" a";
if(ch=='*')
std::cout<<b<<" x "<<c<<"="<<b*c<<" a";
if(ch=='/')
std::cout<<b<<" ¡Â"<<c<<"="<<b/(double)c<<" a";
if(ch=='^')
std::cout<<b<<"µÄ"<<c<<"´Î·½ÊÇ"<<pow(b,c)<<" a";
if(ch=='$')
std::cout<<b<<"µÄ"<<c<<"´Î·½¸ùÔ¼ÊÇ"<<pow(b,1.0/c)<<" a";
if(ch=='!')
std::cout<<"´Ó"<<b<<"³Ëµ½"<<c<<"µÄ»ýÊÇ"<<fun::jiecheng(b,c)<<" a";
if(ch=='#')
std::cout<<b<<"ºÍ"<<c<<"µÄ×î´ó¹«ÒòÊýÊÇ"<<fun::zdgys(b,c)<<" a";
if(ch=='@')
std::cout<<b<<"ºÍ"<<c<<"µÄ×îС¹«±¶ÊýÊÇ"<<fun::zxgbs(b,c)<<" a";
if(b+c>A||b>A||c>A)
std::cout<<"[Error] ²ÎÓë¼ÆËãÁ¿Òѳ¬¹ý×î´óÖµ a";
if(b+c<B||b<B||c<B)
std::cout<<"[Error] ²ÎÓë¼ÆËãÁ¿Òѳ¬¹ý×îСֵ a";
if(ch=='&')
std::cout<<b<<"ºÍ"<<c<<"µÄƽ¾ùÊýÊÇ"<<fun::pingjunshu(b,c)<<" a";
}
}
c语言呐,如果要是说代码的话,输入输出倒是还行,没有打错,一直出不来用编译软件运行再找找错误
从逻辑上来看的话,没什么大问题,谢谢!~