C ++错误表达式不能用作函数 [英] C++ error expression cannot be used as function
本文介绍了C ++错误表达式不能用作函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为
weekday=(day+2(month)+3(month)/5+year+year/4-year/100+year/400)/7
这样我就不会收到一条错误消息,说表达式不能用作函数"?
so that I dont get an error message saying "expression cannot be used as a function"?
#include <iostream>
using namespace std;
int main()
{
int date=0;
int month=0;
int day=0;
int year=0;
int leftover=0;
int weekday=0;
cout<<"Enter Date (ex.20140912) :";
cin>>date;
year=date/10000;
leftover=date%10000;
month=leftover/100;
day=date%100;
{
if (month==3)
{cout<<"March "<< day<<", "<< year<<":";
weekday=(day+2(month)+3(month)/5+year+year/4-year/100+year/400)/7;
if (weekday==0)
{cout<<"Saturday";
}
if (weekday==1)
{cout<<"Sunday";
}
if (weekday==2)
{cout<<"Monday";
}
if (weekday==3)
{cout<<"Tuesday";
}
if (weekday==4)
{cout<<"Wednesday";
}
推荐答案
您需要输入一个运算符(*)进行乘法:
You need to enter an operator (*) for multiplication:
weekday=(day+2*(month)+3*(month)/5+year+year/4-year/100+year/400)/7;
如果缺少运算符,c(++)会将其解释为函数调用,其中函数名称为 2
.
If the operator is missing c(++) interprets it as a function call, wherebthe function name is e.g. 2
.
这篇关于C ++错误表达式不能用作函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文