我正在尝试制作一个程序来检查该数字是奇数,偶数还是素数。但是它给出的错误是"不匹配'运算符>>'" 。 他们为什么我能做到这一点? 。或者有人可以帮我找一个错误来解决它。
#include <iostream>
using namespace std;
void cal(int a, int b,char op)
{
switch(op)
{
case'+':
cout<<a<<"+"<<b<<"="<<a+b<<endl;
break;
case'-':
cout<<a<<"-"<<b<<"="<<a-b<<endl;
break;
case'*':
cout<<a<<"*"<<b<<"="<<a*b<<endl;
break;
case'/':
cout<<a<<"/"<<b<<"="<<a/b<<endl;
break;
case'%':
cout<<a<<"%"<<b<<"="<<a%b<<endl;
break;
default:
cout<<"Invalid operator!"<<endl;
}
}
int main()
{
int a,b;
char op;
cout<<"Enter first number,operator and a second number:"<<endl;
cin>>a>>endl;
cin>>b>>endl;
cin>>op>>endl;
cal(a,b,op);
}
答案 0 :(得分:0)
程序没有完成您所描述的内容,但为了解决编译问题,您应该更改与cin相关的代码行,如下所示:
<div class="col-sm-6 col-md-3">
<div class="td-container">
<!-- content -->
<div class="td-pb-row">
<div class="td-pb-span8 td-main-content">
<div class="td-ss-main-content">
<div class="td-block-row">
<div class="td-block-span6">
<div class="row">
<% @posts.each do |post| %>
<div class="td_module_1 td_module_wrap td-animation-stack">
<div class="td-module-image">
<div class="td-module-thumb"><a href="#" rel="bookmark"><img width="324" height="160" class="entry-thumb" src="https://i.vimeocdn.com/portrait/58832_300x300" width="104" height="142"/></a></div>
</div>
<h2 class="title">
<%= link_to post.naziv, post %>
</h2>
<div class="td-module-meta-info">
<span class="td-post-date"><time class="entry-date updated td-module-date" datetime="2017-06-29T20:26:46+00:00" ><%= post.created_at.strftime("%B, %d, %Y")%></time></span> </div>
</div>
<% end %>
</div>
</div>
</div>
<!-- /.td-container -->
</div>
</div>
</div>
</div>
</div>