首页 > 电脑

帮我看一下程序哪里有问题(C++)

更新时间2020-11-24 09:51:17

#include<bits/stdc++.h> 
using namespace std; 
main() 
{
int a,b,c;
cin>>a>>b;
if(a%400==0)
c="ture";
else if(a%4==0&&a%100!=0)
c="ture";
else
c="false";
}

按你的程序作了修改,程序如下:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
string c;
cin>>a;
if(a%400==0||a%4==0&&a%100!=0)
c="true";
else
c="false";
cout<<c<<endl;
return 0;
}

你的程序主要是错在把字符串常量赋给了整型变量了:

c="ture";

c="false";

程序的三种运行结果如下:

帮我看一下程序哪里有问题(C++)

帮我看一下程序哪里有问题(C++)

帮我看一下程序哪里有问题(C++)


上一篇:有什么网站可以找到人做文案写作推广呢?

下一篇:你的电脑,内存条容量有多大