//【日期】黑色星期五

#include "stdio.h"

#include

#include "math.h"
extern int a;
int fa(int b) //判断为星期几的函数，返回值x

{int c=13,x,y=0;

``````        if(b>12||b<1){
printf("month is error.\n"); goto out;  }
if(a<=1900){
printf("year is error.\n"); goto out;   }
if(((b==1||b==3||b==5||b==7||b==8||b==10||b==12)&&c>31)||(((a%4==0&&a%100!=0)||(a%400==0))&&b==2&&c>29)||((a%4!=0||a%100==0)&&c>28)||((b==6||b==4||b==9||b==11)&&c>31)||(c<1)){
printf("day is error.\n");  goto out; }
switch(b)
{   case 1:x=c%7+1;break;
case 2:x=(31+c)%7+1;break;
case 3:x=(31+28+c)%7+1;break;
case 4:x=(31+28+31+c)%7+1;break;
case 5:x=(31+28+31+30+c)%7+1;break;
case 6:x=(31+28+31+30+31+c)%7+1;break;
case 7:x=(31+28+31+30+31+30+c)%7+1;break;
case 8:x=(31+28+31+30+31+30+31+c)%7+1;break;
case 9:x=(31+28+31+30+31+30+31+31+c)%7+1;break;
case 10:x=(31+28+31+30+31+30+31+31+30+c)%7+1;break;
case 11:x=(31+28+31+30+31+30+31+31+30+31+c)%7+1;break;
case 12:x=(31+28+31+30+31+30+31+31+30+31+30+c)%7+1;break;
}
if(a>2013)x+=(a-2013)/4+(a-2013);
if(a<2013)   {
x-=(2016-a)/4+(2013-a)-7;
x+=7*((2015-x)/7);
}

if(x>=7)x=x%7;
out:
return x;
}

//主函数判断某一年的13号是不是为星期五
int main()
{
int  fa(int b) ;
int i=0,j[10],b,s;

scanf("%d",&a);
for(b=1;b<13;b++){
if(fa(b)==5){
j[i]=b;
i++;
}
}
s=i;
printf("There are %d Black Fridays in year %d.\n",i,a);
printf("They are:\n");

for(i=0;i<s;i++){
printf("%d/%d/13\n",a,j[i]);
}

}
``````
``````
``````

1个回答

`extern int a;`这一句，换成`int a;`就行了。

ubuntu 平台 codeblocks 编译多文件项目时出现error: ld returned 1 exit status 的问题

/*******a.h*******/ #ifndef A_H_INCLUDE #define A_H_INCLUDE void test(); #endif /***********a.cpp***********/ #include <iostream> #include "a.h" using namespace std; void test(){ cout<<"hello"<<endl; } /*********main.cpp************/ #include "a.h" int main() { test(); return 0; } 用codeblocks 编译的时候怎么都无法编译过。一直提示error:ld returned 1 exit status.

Ubuntu codeblocks 编译出现 error:id returned 1 exit status?

```c++ #include<iostream> #include<unistd.h> #include<thread> #include<mutex> using namespace std; void execute(mutex &m,char &i,char t) { for(;true;m.lock(),cout<<"线程"<<t<<"执行中，输入:",cin>>i,cout<<"线程"<<t<<"执行",i==t?cout<<"成功":cout<<"失败",cout<<"。"<<endl,m.unlock(),sleep(1)); } int main(int argc,char *argv[]) { mutex m; char i; thread t([&m,&i]() { execute(m,i,'t'); }),u([&m,&i]() { execute(m,i,'u'); }),v([&m,&i]() { execute(m,i,'v'); }); t.join(); u.join(); v.join(); return 0; } ```

Eclipse下编译通过后，再编提示error: ld returned 1 exit status

RT Eclipse for C++ 每次都是这样，好像是因为编译出的exe运行直接未响应导致的。 按照提示，好像我编译的exe文件还在运行，所以无法编译

collect2.exe: error: ld returned 1 exit status

C++[Error] ld returned 1 exit status

#include<iostream> #include<cmath> using namespace std; class Point { private: int x,y; public: void yidondian(); void xianshijuli(); }; class Line { private: int x,y; public: void diandaozhixianjuli(); void xielvguanxi(); }; class Friangle { private: int x1,x2,x3,y1,y2,y3; public: void panduansanjiaoxing(); void jisuanmianji(); }; void Point::yidondian() { cout<<"输入移动点的坐标"<<endl; cin>>x>>y; cout<<"移动点的坐标为:"<<"("<<x<<","<<y<<")"; } void Point::xianshijuli() { int d; d=sqrt(x*x+y+y); cout<<"点到原点的距离为:"<<endl; } void Line::diandaozhixianjuli() { int a,b,c,d1,d2,d; cout<<"输入点的坐标"<<endl; cin>>x>>y; cout<<"输入直线ax±by+c=0的三个参数abc"<<endl; cin>>a>>b>>c; d1=x*a+b*y+c; d2=sqrt(a*a+b*b); d=d1/d2; if(d>0) { cout<<"点到直线的距离为:"<<d<<endl; } else if(d<0) { int d3; d3=-d; cout<<"点到直线的距离为:"<<d3<<endl; int k; k=-(a/b); if(b!=0) { cout<<"斜率为:"<<k<<endl; } else cout<<"斜率不存在"; } } void Line::xielvguanxi() { int a1,b1,c1,a2,b2,c2,w1,w2,w3; cout<<"输入直线L1 a1x±b1y+c1=0的三个参数a1b1c1"<<endl; cin>>a1>>b1>>c1; cout<<"输入直线L2 a2x±b2y+c2=0的三个参数a2b2c2"<<endl; cin>>a2>>b2>>c2; w1=a1*a2+b1*b2; w2=a1/a2; w3=b1/b2; if(w1==0) { cout<<"两直线互相垂直"; } else if((w2==w3)&&(w3!=c1/c2)) { cout<<"两直线平行"; } else if((w1==w2)&&(w2==w3)) { cout<<"两直线重合"; } else cout<<"两直线相交且不垂直"; } void Friangle::panduansanjiaoxing() { int x1,y1,x2,y2,x3,y3,d1,d2,d3,s1,s2,s3; cout<<"依次输入三个点的坐标"<<endl; cin>>x1>>y1; cin>>x2>>y2; cin>>x3>>y3; d1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); d2=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); d3=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); s1=sqrt(d1*d1+d2*d2); s2=sqrt(d1*d1+d3*d3); s3=sqrt(d2*d2+d3*d3); if(((d1+d2)>d3)&&((d1+d3)>d2)&&((d2+d3)>d1)) { cout<<"能构成三角形"<<endl; if((d1==d2)&&(d2==d3)) { cout<<"此三角形是等边三角形"<<endl; } if(d1==d2||d1==d3||d2==d3) { cout<<"此三角形是等腰三角形"<<endl; } if(s1==d3||s2==d2||s3==d1) { cout<<"此三角形是直角三角形"<<endl; } double p; p=(d1+d2+d3)/2; double s; s=sqrt(p*(p-d1)*(p-d2)*(p-d3)); cout<<"三角形的面积为:"<<s<<endl; } else { cout<<"不能构成三角形"<<endl; } } void menu() { cout<<"=============================="<<endl; cout<<" 菜单 "<<endl; cout<<" Point的功能按<1> "<<endl; cout<<" Line的功能按<2> "<<endl; cout<<" Friangle的功能按<3> "<<endl; cout<<" PolyAngle的功能按<4> "<<endl; cout<<" 退出按<0> "<<endl; cout<<"=============================="<<endl; } void hanshu1() { Point point1; point1.yidondian(); point1.xianshijuli(); } void hanshu2() { Line line1; line1.diandaozhixianjuli(); line1.xielvguanxi(); } void hanshu3() { Friangle friangle1; friangle1.panduansanjiaoxing(); friangle1.jisuanmianji(); } int main() { int i; while(1) { cin>>i; menu(); switch(i) { case 1: hanshu1(); break; case 2: hanshu2(); break; case 3: hanshu3(); break; case 0: exit(0); } } return 0; } 一直有这个问题运行不了。运行了又没有内容？

[Error] ld returned 1 exit status在Dev的运行的程序是错了什么啊？

#include <iostream> using namespace std; class Rectangle { public: Rectangle(int x,int y); int area(); private: int width;int length; }; int Rectangle::area() { return width*length; } int main() { int width; int length; cout<<"enter the width and length of the rectangle:"<<endl; cin>>width>>length; Rectangle A(width,length); cout<<"the area of rectangle a is"<<A.area()<<endl; return 0; }

//此函数找出数组最小值 #include <stdio.h> int minvalue ( int value[10] ) { int minValue , i; minValue = value[0]; for ( i = 1; i<10 ; i++){ if( value[i]<minValue ) minValue = value[i]; } return minValue; } //此函数为主程序 int mian() { printf ("输入十个数字\n"); int value[10]; int i; int minvalue ( int value[10] ); for (i = 0; i<10; i++) value[i] = 0; scanf ("%i", &value[i]); int minscores; minscores = minvalue ( value ); //将一个数组传递给一个函数，只需在调用时列出函数的名字，不需带任何下标。 printf("最小值为%d\n",minscores); return 0; } 求大神解答

linux内核编译报错，求指点？

ubuntu14 下 Caffe编译问题 出错

# .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3'.build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1 make: *** Waiting for unfinished jobs.... .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status .build_release/lib/make: libcaffe.so: undefined reference to *** [.build_release/tools/compute_image_mean.bin] Error 1`cudnnConvolutionBackwardData_v3 ' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/caffe.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/examples/cifar10/convert_cifar_data.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/convert_imageset.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/extract_features.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardData_v3' .build_release/lib/libcaffe.so: undefined reference to `cudnnConvolutionBackwardFilter_v3' collect2: error: ld returned 1 exit status make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1_**

C++初次使用虚函数出现报错不知如何处理

``` #include<iostream> using namespace std; class shape { public: virtual int area(); shape() { cout<<"调用shape构造函数"<<endl; } ~shape() { cout<<"调用shape析构函数"<<endl; } }; class rectangle: public shape { private: int x; int y; public: void in() { cout<<"请输入矩形长宽"<<endl; cin>>x>>y; } virtual int area(); rectangle() { cout<<"调用rectangle构造函数"<<endl; } ~rectangle() { cout<<"调用rectangle析构函数"<<endl; } }; class circle: public shape { private: float r; public: void in() { cout<<"请输入圆形的半径"<<endl; cin>>r; } virtual int area(); circle() { cout<<"调用circle构造函数"<<endl; } ~circle() { cout<<"调用circle析构函数"<<endl; } }; class square: public rectangle { private: int a; public: void in() { cout<<"请输入方形的边长"<<endl; cin>>a; } virtual int area(); square() { cout<<"调用square构造函数"<<endl; } ~square() { cout<<"调用square析构函数"<<endl; } }; int main(void) { circle c; rectangle r; square s; c.in(); r.in(); s.in(); cout<<"圆形面积"<<c.area()<<endl; cout<<"矩形面积"<<r.area()<<endl; cout<<"方形面积"<<s.area()<<endl; } int rectangle::area() { return x*y; } int circle::area() { return 3.14*r*r; } int square::area() { return a*a; } ``` 编译时报错信息为： C:\Users\Administrator\AppData\Local\Temp\ccLhjdDA.o In function `shape::shape()': 10 C:\Users\Administrator\Desktop\未命名2.cpp undefined reference to `vtable for shape' C:\Users\Administrator\AppData\Local\Temp\ccLhjdDA.o In function `shape::~shape()': 15 C:\Users\Administrator\Desktop\未命名2.cpp undefined reference to `vtable for shape' C:\Users\Administrator\Desktop\collect2.exe [Error] ld returned 1 exit status

C##初学者 求大神帮忙解决一下Id returned 1exid status

Making all in support make[1]: Entering directory `/root/httpd-2.4.29/support' make[2]: Entering directory `/root/httpd-2.4.29/support' /usr/local/apr/build-1/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/root/httpd-2.4.29/os/unix -I/root/httpd-2.4.29/include -I/usr/local/apr/include/apr-1 -I/usr/local/apr-util/include/apr-1 -I/root/httpd-2.4.29/modules/aaa -I/root/httpd-2.4.29/modules/cache -I/root/httpd-2.4.29/modules/core -I/root/httpd-2.4.29/modules/database -I/root/httpd-2.4.29/modules/filters -I/root/httpd-2.4.29/modules/ldap -I/root/httpd-2.4.29/modules/loggers -I/root/httpd-2.4.29/modules/lua -I/root/httpd-2.4.29/modules/proxy -I/root/httpd-2.4.29/modules/session -I/root/httpd-2.4.29/modules/ssl -I/root/httpd-2.4.29/modules/test -I/root/httpd-2.4.29/server -I/root/httpd-2.4.29/modules/arch/unix -I/root/httpd-2.4.29/modules/dav/main -I/root/httpd-2.4.29/modules/generators -I/root/httpd-2.4.29/modules/mappers -prefer-non-pic -static -c htpasswd.c && touch htpasswd.lo /usr/local/apr/build-1/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/root/httpd-2.4.29/os/unix -I/root/httpd-2.4.29/include -I/usr/local/apr/include/apr-1 -I/usr/local/apr-util/include/apr-1 -I/root/httpd-2.4.29/modules/aaa -I/root/httpd-2.4.29/modules/cache -I/root/httpd-2.4.29/modules/core -I/root/httpd-2.4.29/modules/database -I/root/httpd-2.4.29/modules/filters -I/root/httpd-2.4.29/modules/ldap -I/root/httpd-2.4.29/modules/loggers -I/root/httpd-2.4.29/modules/lua -I/root/httpd-2.4.29/modules/proxy -I/root/httpd-2.4.29/modules/session -I/root/httpd-2.4.29/modules/ssl -I/root/httpd-2.4.29/modules/test -I/root/httpd-2.4.29/server -I/root/httpd-2.4.29/modules/arch/unix -I/root/httpd-2.4.29/modules/dav/main -I/root/httpd-2.4.29/modules/generators -I/root/httpd-2.4.29/modules/mappers -prefer-non-pic -static -c passwd_common.c && touch passwd_common.lo /usr/local/apr/build-1/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o htpasswd htpasswd.lo passwd_common.lo /usr/local/apr-util/lib/libaprutil-1.la /usr/local/apr/lib/libapr-1.la -lrt -lcrypt -lpthread -ldl -lcrypt /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString' /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler' collect2: error: ld returned 1 exit status make[2]: *** [htpasswd] Error 1 make[2]: Leaving directory `/root/httpd-2.4.29/support' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/httpd-2.4.29/support' make: *** [all-recursive] Error 1 [root@bogon httpd-2.4.29]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite --libdir=/usr/lib64^C [root@bogon httpd-2.4.29]# ll /usr/lib/libm libm-2.17.so libmemusage.so libm.so.6 [root@bogon httpd-2.4.29]# ll /usr/lib/libelf libelf-0.168.so libelf.so.1 [root@bogon httpd-2.4.29]# ll /usr/lib/libelf libelf-0.168.so libelf.so.1 ----------------以上为make后的信息------------- 安装根据http://blog.csdn.net/bizu005/article/details/78339380?locationNum=4&fps=1教程进行操作 环境如下：Centos7.4 编译安装的apache版本为2.4.29 已执行过的操作： 1.安装依赖包yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel 2.添加配置 --libdir=/usr/lib64 3.根据http://www.ti6.net/wangzhanjishu/1587.html所示，但是并未在mv /usr/lib/路径下 找到 libm.a，libm.so，libexpat.so只有一下文件libm-2.17.so libmemusage.so libm.so.6 ![图片说明](https://img-ask.csdn.net/upload/201801/23/1516697165_357009.png)

Linux服务器上编译报错

makefile 编译文件的时候提示这个错误,试过网上很多方法，还是报错，在线等

/usr/bin/ld: zdatabase.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status makefile:23: recipe for target 'hello' failed make: *** [hello] Error 1

ubuntu中c的编译问题（有报错）

MySQL数据库面试题（2020最新版）

2020阿里全球数学大赛：3万名高手、4道题、2天2夜未交卷

Python爬虫，高清美图我全都要（彼岸桌面壁纸）

Java岗开发3年，公司临时抽查算法，离职后这几题我记一辈子