第八周任务4

#include <iostream>  
#include <cmath>
using namespace std;  
class CFraction  
{  
private:  
    int nume;  // 分子  
    int deno;  // 分母  
public:  
    CFraction(int nu=0,int de=1):nume(nu),deno(de){}  
    void simplify();  
    void display();  
    CFraction operator+(const CFraction &c);  
    CFraction operator-(const CFraction &c);  
    CFraction operator*(const CFraction &c);  
    CFraction operator/(const CFraction &c);  
    CFraction operator+();  
    CFraction operator-(); 
      bool operator>(const CFraction &c);  
     bool operator<(const CFraction &c);  
     bool operator==(const CFraction &c);  
    bool operator>=(const CFraction &c);  
    bool operator<=(const CFraction &c);
 friend CFraction operator+( CFraction &c,int i);  
    friend CFraction operator-( CFraction &c,int i);  
    friend CFraction operator*( CFraction &c,int i);   
    friend CFraction operator/( CFraction &c,int i); 
};  
 
// 分数化简  
void CFraction::simplify()  //借鉴的老师的方法;
{  
    int m,n,r;  
    m=abs(deno);  
    n=abs(nume);  
    while(r=m%n)  // 求m,n的最大公约数  
    {  
       m=n;  
        n=r;  
    }  
    deno/=n;     // 化简  
    nume/=n;  
    if (deno<0)  // 将分母转化为正数  
   {  
       deno=-deno;  
       nume=-nume;  
    }  
} 
void CFraction::display()
{
 cout<<nume<<"/"<<deno<<endl;
}
CFraction CFraction::operator+(const CFraction &c)
{
 CFraction  t;
 t.deno = c.deno * deno;
 t.nume = deno * c.nume + c.deno * nume;
 t.simplify();
 return t;
}

CFraction CFraction::operator-(const CFraction &c)
{
 CFraction  t;
 t.deno = c.deno * deno;
 t.nume = c.deno * nume - deno * c.nume;
 t.simplify();
 return t;
}

CFraction CFraction::operator*(const CFraction &c)
{
 CFraction  t;
 t.deno = c.deno * deno;
 t.nume = nume * c.nume;
 t.simplify();
 return t;
}

CFraction CFraction::operator/(const CFraction &c)
{
 CFraction  t;
 t.deno = c.nume * deno;
 t.nume = nume * c.deno;
 t.simplify();
 return t;
}

CFraction CFraction::operator+()
{
 CFraction t;
 t.deno = deno;
 t.nume = nume;
 t.simplify();
 return t;
}
CFraction CFraction::operator-() 
{
 CFraction t;
 t.deno = deno;
 t.nume = -nume;
 t.simplify();
 return t;
}

bool CFraction::operator>(const CFraction &c) 
{
 int t1_nume,t1_deno,t2_nume,t2_deno;
 t1_nume = deno * c.nume ;
 t1_deno = c.deno * deno;
 t2_nume = c.deno * nume ;
 t2_deno = c.deno * deno;
 if(t1_nume  > t2_nume)
  return true;
 else 
  return false;
}
bool CFraction::operator<(const CFraction &c)  
{
 int t1_nume,t1_deno,t2_nume,t2_deno;
 t1_nume = deno * c.nume ;
 t1_deno = c.deno * deno;
 t2_nume = c.deno * nume ;
 t2_deno = c.deno * deno;
 if(t1_nume < t2_nume)
  return true;
 else 
  return false;
}

bool CFraction::operator==(const CFraction &c)
{
 int t1_nume,t1_deno,t2_nume,t2_deno;
 t1_nume = deno * c.nume ;
 t1_deno = c.deno * deno;
 t2_nume = c.deno * nume ;
   t2_deno = c.deno * deno;
 if(t1_nume == t2_nume)
  return true;
 else 
  return false;
}

bool CFraction::operator>=(const CFraction &c)
{
 int t1_nume,t1_deno,t2_nume,t2_deno;
 t1_nume = deno * c.nume ;
 t1_deno = c.deno * deno;
 t2_nume = c.deno * nume ;
 t2_deno = c.deno * deno;
 if(t1_nume >= t2_nume)
  return true;
 else 
  return false;
}
bool CFraction::operator<=(const CFraction &c)  
{
 int t1_nume,t1_deno,t2_nume,t2_deno;
 t1_nume = deno * c.nume ;
 t1_deno = c.deno * deno;
 t2_nume = c.deno * nume ;
 t2_deno = c.deno * deno;
 if( t1_nume <= t2_nume)
  return true;
 else 
  return false;
}

CFraction operator+( CFraction &c,int i)
{
 CFraction c1(c.nume + c.deno * i ,c.deno );
  c1.simplify();
  return c1;
}

CFraction operator-( CFraction &c,int i) 
{
  CFraction c1(c.nume - c.deno * i , c.deno);
  c1.simplify();
  return c1;
}

CFraction operator*( CFraction &c,int i)
{
 CFraction c1(c.nume * i,c.deno);
  c1.simplify();
  return c1;
}
CFraction operator/( CFraction &c,int i)
{
  CFraction c1(c.nume ,c.deno * i);
  c1.simplify();
  return c1;
}

int main()
{
   CFraction c1(3,5),c2(4,8),t,c3;
   t = c1 + c2;
   cout<<"c1 + c2 = ";
   t.display();
   t = c1 - c2;
   cout<<"c1 - c2 = ";
   t.display();

   t = c1 * c2;
   cout<<"c1 * c2 = ";
   t.display();

   t = c1 / c2;
   cout<<"c1 / c2 = ";
   t.display();

   t = c1;
   cout<<"t = ";
   t.display();

   t = -c1;
   cout<<"-t = ";
   t.display();

   c1.display();
   if(c1 > c2) cout<< "   > 并且 ";
   if(c1 < c2) cout<<"    < 并且";
   if(c1 == c2) cout<<" == ";
   if(c1 >= c2) cout<<" >= ";
   if(c1 <= c2) cout<<" <= ";
   c2.display();

   c3 = c1 + 3;
   cout<<"c1+3= ";
   c3.display();
   
   c3 = c1 - 3;
   cout<<"c1-3= ";
   c3.display();

   c3 = c1 * 3;
   cout<<"c1*3= ";
   c3.display();

   c3 = c1 / 3;
   cout<<"c1/3= ";
   c3.display();

   system("pause");

   return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是更详细的网络安全专业8实习任务和计划安排: 第1任务: - 熟悉公司的网络安全政策和实践,了解公司的网络架构和安全措施 - 学习使用网络安全工具,如漏洞扫描器、入侵检测系统等。 计划: - 与网络安全团队和IT部门的成员会面,了解公司网络安全政策和实践。 - 学习公司的网络架构和安全措施,包括网络拓扑图、网络设备和安全措施等。 - 学习如何使用网络安全工具,包括如何进行漏洞扫描、入侵检测、网络嗅探等。 第2任务: - 学习网络加密技术和信息安全标准 - 学习常见的攻击类型和防御策略 - 参与网络安全演练和模拟攻击。 计划: - 学习加密技术和安全标准,如SSL、TLS、IPSec、AES等。 - 学习常见的攻击类型和防御策略,如DoS、DDoS、SQL注入等。 - 参与网络安全演练和模拟攻击,测试公司的安全措施和应对能力。 第3-4任务: - 学习安全审计和风险评估方法 - 参与公司的安全审计和风险评估工作 - 学习如何编写网络安全策略和安全计划。 计划: - 学习安全审计和风险评估方法,如ISO 27001、PCI DSS等。 - 参与公司的安全审计和风险评估工作,包括安全漏洞扫描、安全评估、风险评估等。 - 学习如何编写网络安全策略和安全计划,包括安全政策、安全规范、安全手册等。 第5-6任务: - 参与网络安全事件的响应和处理 - 参与网络安全事件的调查和取证工作 - 学习如何处理网络安全事件的后续工作。 计划: - 学习如何进行网络安全事件的响应和处理,包括如何发现和报告安全事件、如何采取应对措施等。 - 参与网络安全事件的调查和取证工作,包括事件分析、日志分析、恶意代码分析等。 - 学习如何处理网络安全事件的后续工作,包括如何修复漏洞、如何改进安全措施等。 第7任务: - 学习如何进行网络安全培训和教育 - 参与网络安全培训和教育的活动 - 学习如何进行网络安全宣传和推广。 计划: - 学习如何进行网络安全培训和教育,包括如何制定培训计划、如何开展培训活动等。 - 参与网络安全培训和教育的活动,包括向员工进行安全培训、向客户进行安全宣传等。 - 学习如何进行网络安全宣传和推广,包括如何发布安全公告、如何进行安全宣传等。 第8任务: - 总结实习期间的工作和学习成果 - 提出网络安全改进建议和意见 - 参加实习结业评估和反馈。 计划: - 总结实习期间的工作和学习成果,包括参与的项目、学习的知识等。 - 提出网络安全改进建议和意见,包括对公司网络安全政策和实践的建议。 - 参加实习结业评估和反馈,包括对实习过程和公司的评价、对未来发展的展望等。 以上是一个较为详细的实习任务和计划安排,具体的实习内容还需要根据公司的实际情况和实习生的能力进行调整和安排。希望对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值