• 关于

    include()

    的搜索结果

问题

linux c socket tcp客户端只能发送一次,发送第二次服务端接收不到,必须重启才行

杨冬芳 2019-12-01 20:26:33 2254 浏览量 回答数 1

问题

用socket写了个linux聊天的小程序,一客户端一直输出接受消息成功 ==

小旋风柴进 2019-12-01 19:41:51 895 浏览量 回答数 1

回答

x = A.ldlt().solve(b)); // A sym. p.s.d. #include x = A.llt() .solve(b)); // A sym. p.d. #include x = A.lu() .solve(b)); // Stable and fast. #include x = A.qr() .solve(b)); // No pivoting. #include x = A.svd() .solve(b)); // Stable, slowest. #include // .ldlt() -> .matrixL() and .matrixD()// .llt() -> .matrixL()// .lu() -> .matrixL() and .matrixU()// .qr() -> .matrixQ() and .matrixR()// .svd() -> .matrixU(), .singularValues(), and .matrixV()

a123456678 2019-12-02 01:59:29 0 浏览量 回答数 0

万券齐发助力企业上云,爆款产品低至2.2折起!

限量神券最高减1000,抢完即止!云服务器ECS新用户首购低至0.95折!

问题

linux socket tcp 为什么总是:newfd = 0,出现还很多

a123456678 2019-12-01 19:52:51 1045 浏览量 回答数 1

问题

Linux fork 多进程 实现拷贝文件 四个进程拷贝

康康——康 2019-12-01 19:23:23 1493 浏览量 回答数 0

问题

linux虚拟机与windows间socket通信问题

杨冬芳 2019-12-01 20:22:30 1134 浏览量 回答数 1

问题

`pause()` 疑似阻塞,害得循环无法终止。

a123456678 2019-12-01 19:48:20 854 浏览量 回答数 1

回答

#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<string> #include<queue> #include<map> #include<cmath> #include<stack> #include<algorithm> #include<functional> #include<stdarg.h> using namespace std; #ifdef __int64 typedef __int64 LL; #else typedef long long LL; #endif struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} ListNode(int x, ListNode *next) : val(x), next(next) {} ListNode():next(NULL) {} } str[100]; ListNode *deleteDuplicates(ListNode *head) { while(head && head->next) { if(head->val==head->next->val) { head->next = head->next->next; } else { head = head->next; } } return head; } ListNode *oldDeleteDuplicates(ListNode *head) { ListNode **pcur=&head; //取得 head 变量的 if(head==NULL||head->next==NULL) {//特判是不是没有元素或者只有一个元素 return head; } /* 这个时候 head 是 one 的地址。 pcur 是 head 的地址。 *pcur 就代表 head 了,即 one (*pcur)->nex 指向 two,所以不结束循环,且比较相等了 所以你给 *pcur 赋值,也就是给 head 赋值。 此时 *pcur 就指向 two 了。 */ while((*pcur)->next!=NULL) { if((*pcur)->val==(*pcur)->next->val) { *pcur=(*pcur)->next; // (*pcur)->next =((*pcur)->next->next); } else { pcur=&((*pcur)->next); } } return head; } void testAsignPoint(ListNode *head) { printf(" asign begin=%0x\n",head); head = head->next; printf(" asign begin=%0x\n",head); } void myprintf(ListNode* head) { while(head != NULL) { printf("%d ", head->val); head=head->next; } printf("\n"); } void testAsignPointAgain(unsigned int addr){ printf(" asign begin=%0x\n",addr); addr = (unsigned int)((ListNode *)addr)->next;//28fef8 printf(" asign begin=%0x\n",addr); } void test(ListNode* ptest) { printf("ptest begin=%0x\n",ptest);//28fef0 testAsignPoint(ptest); printf("one ptest =%0x\n",ptest);//28fef0 printf("same as before code"); testAsignPointAgain((unsigned int)(ptest)); printf("one ptest =%0x\n",ptest);//28fef0 printf("ptest=%0x\n",ptest); myprintf(ptest); oldDeleteDuplicates(ptest); myprintf(ptest); deleteDuplicates(ptest); printf("ptest=%0x\n",ptest); myprintf(ptest); } void testSample(){ ListNode three(1, NULL); ListNode two(0, &three); ListNode one(0, &two); test(&one); } int main() { int n = 10; for(int i=0; i<n; i++) { str[i].val = i/2; str[i].next = &str[i+1]; } str[n].val = n/2; str[n].next = NULL; printf("deleteDuplicates begin\n"); myprintf(str); deleteDuplicates(&str[0]); myprintf(str); printf("deleteDuplicates end\n"); printf("\n"); printf("test Asign Point begin\n"); testSample(); printf("test Asign Point begin\n"); return 0; }

a123456678 2019-12-02 02:37:24 0 浏览量 回答数 0

问题

c语言在linux环境下进行文件复制的代码,使用时出错,求各位大神帮忙解答下

杨冬芳 2019-12-01 20:22:01 1066 浏览量 回答数 1

问题

OpenGL初学,请问我这段代码有错吗?为什么在窗口显示不出来

a123456678 2019-12-01 20:10:30 869 浏览量 回答数 1

回答

Widgets.h(记得包含你自己代码的头文件) #ifndef WIDGET_H #define WIDGET_H #include <QWidget> #include <QPushButton> #include <QLayout> class Widget : public QWidget { Q_OBJECT public: explicit Widget(QWidget *parent = 0); private: QPushButton *runPushButton; QPushButton *exitPushButton; private slots: void run(); }; #endif // WIDGET_H Widget.cpp #include "Widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) { setWindowTitle("Title"); // button runPushButton = new QPushButton("&Go"); exitPushButton = new QPushButton("&Exit"); // layout QHBoxLayout *hl = new QHBoxLayout; hl->addWidget(runPushButton); hl->addWidget(exitPushButton); setLayout(hl); // signals and slots connect(runPushButton, SIGNAL(clicked()), this, SLOT(run())); connect(exitPushButton, SIGNAL(clicked()), this, SLOT(close())); } void Widget::run() { // run your c++ code } main.cpp #include "Widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } 将你的要执行的代码放到Widget::run()中即可

a123456678 2019-12-02 02:00:27 0 浏览量 回答数 0

问题

c语言socket的一个比较怪的菜鸟问题

a123456678 2019-12-01 20:11:54 991 浏览量 回答数 1

回答

I assume you can make sense of my code!so i just show you code below,if you have any question,just let me know !!1 server.c #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #define BUF_SIZE 1024 #define LISTEN_PORT 8889 #define LISTEN_NO 10 #define err_exit(msg) (perror(msg),(exit(EXIT_FAILURE))) int sock_make(void); void read_from(int fd); void send_to(int fd); int main(void) { int sockfd,connfd; struct sockaddr_in clientaddr; int n; char buf[BUF_SIZE]; char recvbuf[BUF_SIZE]; char sendbuf[BUF_SIZE]; sockfd=sock_make(); while(1){ //If you wanna know which client and what the ip is //You should no set the the argu being NULL .. if((connfd=accept(sockfd,(struct sockaddr*)NULL,NULL))<0) { err_exit(">>accept"); }else{ while(1){ puts("-----------wait message---------"); KEEP_READ: n=read(connfd,recvbuf,sizeof(recvbuf)); //recvbuf[n]=0; printf("%s\n",recvbuf); if(strncmp(recvbuf,".",1)) goto KEEP_READ; puts("-----------Please input----------"); KEEP_SEND: n=read(STDIN_FILENO,sendbuf,sizeof(sendbuf)); sendbuf[n]=0; write(connfd,sendbuf,sizeof(sendbuf)); if(strncmp(sendbuf,".",1)) goto KEEP_SEND; } close(connfd); } } close(sockfd); return 0; } int sock_make(void) { struct sockaddr_in clientaddr; int sockfd; memset(&clientaddr,SOCK_STREAM,sizeof(clientaddr)); clientaddr.sin_family=AF_INET; clientaddr.sin_port=htons(LISTEN_PORT); clientaddr.sin_addr.s_addr=htonl(INADDR_ANY); if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { err_exit(">>socket"); } if(bind(sockfd,(struct sockaddr*)&clientaddr,sizeof(clientaddr))<0) { err_exit(">>bind"); } listen(sockfd,LISTEN_NO); return sockfd; } client.c #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #define BUF_SIZE 1024 #define LISTEN_PORT 8889 #define LISTEN_NO 10 #define err_exit(msg) (perror(msg),(exit(EXIT_FAILURE))) int main(int argc,char * argv[]) { int sockfd; int n; struct sockaddr_in serverAddr; char sendbuf[BUF_SIZE]; char recvbuf[BUF_SIZE]; if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0) { err_exit(">>socket"); } memset(&serverAddr,0,sizeof(serverAddr)); serverAddr.sin_family=AF_INET; serverAddr.sin_port=htons(LISTEN_PORT); inet_pton(PF_INET,argv[1],&serverAddr.sin_addr.s_addr); while(1) { if((connect(sockfd,(struct sockaddr*)&serverAddr,sizeof(serverAddr)))<0) { err_exit(">>connect"); }else{ while(1){ puts("--------------Please input-----------"); KEEP_SEND: n=read(STDIN_FILENO,sendbuf,sizeof(sendbuf)); sendbuf[n]=0; write(sockfd,sendbuf,sizeof(sendbuf)); if(strncmp(sendbuf,".",1)) goto KEEP_SEND; puts("-------------Wait message------------"); KEEP_READ: n=read(sockfd,recvbuf,sizeof(recvbuf)); //recvbuf[n]=0; //EOF .. printf("%s\n",recvbuf); if(strncmp(recvbuf,".",1)) goto KEEP_READ; } close(sockfd); } } return 0; } Please ,run the client as : ./client 127.0.0.1 if you run the both on both terminal and you see something below: terminal 1 (run server) landpack@landpack-VirtualBox:~/ak/csdn$ ./server -----------wait message--------- hello I am Landpack . -----------Please input---------- Hey Landpack ! good to know you . -----------wait message--------- terminal 2 (run client) landpack@landpack-VirtualBox:~/ak/csdn$ ./client 127.0.0.1 --------------Please input----------- hello I am Landpack . -------------Wait message------------ Hey Landpack ! good to know you . --------------Please input----------- All suggestion are welcome ! Have fun !!

杨冬芳 2019-12-02 03:07:29 0 浏览量 回答数 0

回答

#define MAXADDRS 32 extern char *if_names[MAXADDRS]; extern char *ip_names[MAXADDRS]; extern char *hw_addrs[MAXADDRS]; extern unsigned long ip_addrs[MAXADDRS]; // Function prototypes void InitAddresses(); void FreeAddresses(); void GetIPAddresses(); void GetHWAddresses(); IPAddress.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <sys/sockio.h> #include <net/if.h> #include <errno.h> #include <net/if_dl.h> #include <net/ethernet.h> #include "IPAddress.h" #define min(a,b) ((a) < (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b)) #define BUFFERSIZE 4000 char *if_names[MAXADDRS]; char *ip_names[MAXADDRS]; char *hw_addrs[MAXADDRS]; unsigned long ip_addrs[MAXADDRS]; static int nextAddr = 0; void InitAddresses() { int i; for (i=0; i<MAXADDRS; ++i) { if_names[i] = ip_names[i] = hw_addrs[i] = NULL; ip_addrs[i] = 0; } } void FreeAddresses() { int i; for (i=0; i<MAXADDRS; ++i) { if (if_names[i] != 0) free(if_names[i]); if (ip_names[i] != 0) free(ip_names[i]); if (hw_addrs[i] != 0) free(hw_addrs[i]); ip_addrs[i] = 0; } InitAddresses(); } void GetIPAddresses() { int i, len, flags; char buffer[BUFFERSIZE], *ptr, lastname[IFNAMSIZ], *cptr; struct ifconf ifc; struct ifreq *ifr, ifrcopy; struct sockaddr_in *sin; char temp[80]; int sockfd; for (i=0; i<MAXADDRS; ++i) { if_names[i] = ip_names[i] = NULL; ip_addrs[i] = 0; } sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { perror("socket failed"); return; } ifc.ifc_len = BUFFERSIZE; ifc.ifc_buf = buffer; if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0) { perror("ioctl error"); return; } lastname[0] = 0; for (ptr = buffer; ptr < buffer + ifc.ifc_len; ) { ifr = (struct ifreq *)ptr; len = max(sizeof(struct sockaddr), ifr->ifr_addr.sa_len); ptr += sizeof(ifr->ifr_name) + len; // for next one in buffer if (ifr->ifr_addr.sa_family != AF_INET) { continue; // ignore if not desired address family } if ((cptr = (char *)strchr(ifr->ifr_name, ':')) != NULL) { *cptr = 0; // replace colon will null } if (strncmp(lastname, ifr->ifr_name, IFNAMSIZ) == 0) { continue; /* already processed this interface */ } memcpy(lastname, ifr->ifr_name, IFNAMSIZ); ifrcopy = *ifr; ioctl(sockfd, SIOCGIFFLAGS, &ifrcopy); flags = ifrcopy.ifr_flags; if ((flags & IFF_UP) == 0) { continue; // ignore if interface not up } if_names[nextAddr] = (char *)malloc(strlen(ifr->ifr_name)+1); if (if_names[nextAddr] == NULL) { return; } strcpy(if_names[nextAddr], ifr->ifr_name); sin = (struct sockaddr_in *)&ifr->ifr_addr; strcpy(temp, inet_ntoa(sin->sin_addr)); ip_names[nextAddr] = (char *)malloc(strlen(temp)+1); if (ip_names[nextAddr] == NULL) { return; } strcpy(ip_names[nextAddr], temp); ip_addrs[nextAddr] = sin->sin_addr.s_addr; ++nextAddr; } close(sockfd); } void GetHWAddresses() { struct ifconf ifc; struct ifreq *ifr; int i, sockfd; char buffer[BUFFERSIZE], *cp, *cplim; char temp[80]; for (i=0; i<MAXADDRS; ++i) { hw_addrs[i] = NULL; } sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { perror("socket failed"); return; } ifc.ifc_len = BUFFERSIZE; ifc.ifc_buf = buffer; if (ioctl(sockfd, SIOCGIFCONF, (char *)&ifc) < 0) { perror("ioctl error"); close(sockfd); return; } ifr = ifc.ifc_req; cplim = buffer + ifc.ifc_len; for (cp=buffer; cp < cplim; ) { ifr = (struct ifreq *)cp; if (ifr->ifr_addr.sa_family == AF_LINK) { struct sockaddr_dl *sdl = (struct sockaddr_dl *)&ifr->ifr_addr; int a,b,c,d,e,f; int i; strcpy(temp, (char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl))); sscanf(temp, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f); sprintf(temp, "%02X:%02X:%02X:%02X:%02X:%02X",a,b,c,d,e,f); for (i=0; i<MAXADDRS; ++i) { if ((if_names[i] != NULL) && (strcmp(ifr->ifr_name, if_names[i]) == 0)) { if (hw_addrs[i] == NULL) { hw_addrs[i] = (char *)malloc(strlen(temp)+1); strcpy(hw_addrs[i], temp); break; } } } } cp += sizeof(ifr->ifr_name) + max(sizeof(ifr->ifr_addr), ifr->ifr_addr.sa_len); } close(sockfd); } 使用的方法 - (void)getIPAddress { InitAddresses(); GetIPAddresses(); GetHWAddresses(); int i; NSString *deviceIP = nil; for (i=0; i<MAXADDRS; ++i) { static unsigned long localHost = 0x7F000001; // 127.0.0.1 unsigned long theAddr; theAddr = ip_addrs[i]; if (theAddr == 0) break; if (theAddr == localHost) continue; NSLog(@"Name: %s MAC: %s IP: %s\n", if_names[i], hw_addrs[i], ip_names[i]); } } [self getIPAddress]就能获取当前IP地址。 2013年6月11日添加 今天我项目添加一个功能,实时检测设备IP地址,发现上述代码FreeAddress也无用。 在http://stackoverflow.com/questions/7072989/iphone-ipad-how-to-get-my-ip-address-programmatically有更为简单的获取IP地址的方法,并且能实时更新。

a123456678 2019-12-02 03:13:02 0 浏览量 回答数 0

回答

最后一个字符大哥,你少;号这个是函数<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">voidHisuTestSOMSApiForDP(charinput){}可能出错原因是贴一下上下文#include"hisuStrFunGrp.h"#include"hisuTimeFunGrp.h"#include"hisuRunningLog.h"#include"hisuErrCodeDef.h"#include"hisuFileAndDirFunGrp.h"#include"hisuPackRules.h"#include"hisuPackFldTagDef.h"#include"hisuSOMSApiForDP.h"voidHisuTestSOMSApiForDP(charinput){switch(atoi(input)){case1:HisuGetIssueBankCertificationTest();break;case2:HisuGenICCUDKsTest();break;case3:HisuGenICCRSATest();break;case4:HisuGenICCCertAndStaticDataTest();break;case5:HisuEncryptDataFromKeyAToKeyBTest();break;case6:HisuEncryptDataBySpecKeyTest();break;case7:HisuDecryptDataBySpecKeyTest();break;case8:HisuGetICCardVerifyValueTest();break;case9:HisuExpKMUTest();break;case10:HisuGenDataMACTest();break;case11://HisuGetICCSpecDataTest();break;case12:HisuGenKeyFromRootKeyTest();break;case13:HisuGenDataMACOfSpecAlgTest();break;case14:HisuEncryptByKeyOfSpecAlgTest();break;case15:HisuEncryptFromKeyAToKeyBOfSpecAlgTest();break;case16:HisuGenKeyFromKMCTest();break;case17:HisuGenSessionKeyFromKMCTest();break;case18:HisuGenKeyFromKMUTest();break;case19:HisuEncryptDataFromTKToSessionKeyTest();break;case20:HisuEncryptDataFromSessionKeyAToSessionKeyBTest();break;case21:HisuGenDataMACBySessionKeyTest();break;case22:HisuEncryptDataBySessionKeyTest();break;case23:HisuDecryptDataBySessionKeyTest();break;case24:HisuGenRandDataOfSpecLenTest();break;case25:HisuEncryptKeyFromTKToLMKTest();break;case26:HisuGenKeyFromKMCTest();HisuGenSessionKeyFromKMCTest();HisuGenKeyFromKMUTest();HisuEncryptDataFromTKToSessionKeyTest();HisuEncryptDataFromSessionKeyAToSessionKeyBTest();HisuGenDataMACBySessionKeyTest();HisuEncryptDataBySessionKeyTest();HisuDecryptDataBySessionKeyTest();HisuGenRandDataOfSpecLenTest();HisuEncryptKeyFromTKToLMKTest();break;case27:HisuGenKeysBySpecKeyOfPBOC10Test();break;case28:HisuEncryptDataBySpecKeyOfPBOC10Test();break;case29:HisuDecryptDataBySpecKeyOfPBOC10Test();break;case30:HisuGenICCUDKSMTest();break; case31:  HisuGetIssueBankCertificationSMTest();  break; case32:  HisuGenICCSMTest();  break; case33:  HisuGenICCCertAndStaticDataSMTest();  break;default:printf("选择的[%d]接口不存在\n",atoi(input));break;}return;}<atarget='_blank'>@aoniao还是一样<atarget='_blank'>@aoniao插入代码也不好使<atarget='_blank'>@aoniao不好意思,我是个新手。不太明白。求指示为什么不用插入代码功能编辑一下代码?把整个函数体注释掉看看,有可能是头文件的问题。注掉同样报错估计是你文件的格式问题,里面隐含了不可及字符,代码看起来正常。

爱吃鱼的程序员 2020-06-22 11:24:38 0 浏览量 回答数 0

回答

@吥楛糖 ,求指导,谢谢######继承QLineEdit,派生类里实现 mousePressEvent或者mouseReleaseEvent函数就行了  ###### 用selectionChanged信号 或 重写focusInEvent 事件 或 mousePressEvent 事件 ######这个你可以自己做一个信号槽的,自定义一下槽和信号就好了。 如果你想要实现鼠标一放进去就响应clicked()的话,可以在QLineEdit的派生类的keyPressEvent()里发送一个信号出去######qMyEdit.h #ifndef QMYEDIT_H #define QMYEDIT_H #include <QtGui> class QMyEdit : public QLineEdit { Q_OBJECT public: explicit QMyEdit(QWidget *parent = 0); protected: virtual void mousePressEvent(QMouseEvent *event); private slots: signals: void LineEditClicked(); }; #endif // QMYEDIT_H qMyEdit.cpp #include "qmyedit.h" QMyEdit::QMyEdit(QWidget *parent) : QLineEdit(parent) { } void QMyEdit::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { emit LineEditClicked(); } QLineEdit::mousePressEvent(event); } mainWindow.h #include "qmyedit.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void myEditClicked(); private: Ui::MainWindow *ui; QMyEdit *pMyEdit; }; #endif // MAINWINDOW_H mainWindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->lineEdit->setVisible(false); pMyEdit = new QMyEdit(this); QRect rect = ui->lineEdit->geometry(); pMyEdit->setGeometry(rect); connect(pMyEdit, SIGNAL(LineEditClicked()), this, SLOT(myEditClicked())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::myEditClicked() { qDebug() << "clicked!!!"; } ###### 引用来自“吥楛糖”的答案 qMyEdit.h #ifndef QMYEDIT_H #define QMYEDIT_H #include <QtGui> class QMyEdit : public QLineEdit { Q_OBJECT public: explicit QMyEdit(QWidget *parent = 0); protected: virtual void mousePressEvent(QMouseEvent *event); private slots: signals: void LineEditClicked(); }; #endif // QMYEDIT_H qMyEdit.cpp #include "qmyedit.h" QMyEdit::QMyEdit(QWidget *parent) : QLineEdit(parent) { } void QMyEdit::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { emit LineEditClicked(); } QLineEdit::mousePressEvent(event); } mainWindow.h #include "qmyedit.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void myEditClicked(); private: Ui::MainWindow *ui; QMyEdit *pMyEdit; }; #endif // MAINWINDOW_H mainWindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->lineEdit->setVisible(false); pMyEdit = new QMyEdit(this); QRect rect = ui->lineEdit->geometry(); pMyEdit->setGeometry(rect); connect(pMyEdit, SIGNAL(LineEditClicked()), this, SLOT(myEditClicked())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::myEditClicked() { qDebug() << "clicked!!!"; } 真是太谢谢你了,离成功差一步,我的理解还是不够清楚,谢谢

kun坤 2020-06-10 09:22:10 0 浏览量 回答数 0

问题

关于在VS2008中的错误:error C2660: “cvCreateImage”: 函数不接受 1 个参数

a123456678 2019-12-01 20:07:21 1495 浏览量 回答数 1

回答

#if 1 #include #include #include #include #include using namespace std; class Student_Info { private: string name; int mid, final; public: Student_Info() : name(" "), mid(0), final(0){}; //默认构造函数 Student_Info(string s, int x, int y); ~Student_Info(){} void input(string s, int x, int y); //读入学生成绩数据 inline string output_name(){ return name; } //输出学生姓名 inline bool pass(){ return ((mid + final) >= 60) ? 1 : 0; } //判断是否及格 }; void Student_Info::input(string s, int x, int y) { name = s; mid = x; final = y; } Student_Info::Student_Info(string s, int x, int y) { input(s, x, y); } char grade(Student_Info student) { return student.pass() ? 'P' : 'F'; } int string2int(string txt) { int num; stringstream ss; ss >> num; if (!ss.good()) { cerr << "转换失败!" << endl; exit(1); } return num; } int max(int x, int y) { return x > y ? x : y; } int main() { vector students; vector pass; vector temp, names; vector points; string tmp, str; int x, y, i = 0, length = 0; Student_Info student; ifstream fin("data.txt"); ofstream fout("result.txt"); getline(fin, tmp); //cout< while(getline(fin,tmp)) { istringstream stream(tmp); while (stream >> str) temp.push_back(str); x = string2int(temp[1]); y = string2int(temp[2]); student.input(temp[0], x, y); students.push_back(student); pass.push_back(grade(student)); names.push_back(student.output_name()); temp.clear(); } for (; i<names.size(); i++) { if (length<names[i].size()) length = names[i].size(); } length = max(length, 12); fout << left << setw(length) << "学生姓名" << "学生成绩" << endl; for (i = 0; i<names.size(); i++) fout << left << setw(length) << names[i] << pass[i] << endl; fin.close(); fout.close(); system("pause"); return 0; } #endif

a123456678 2019-12-02 01:57:14 0 浏览量 回答数 0

回答

表法式 str=Regex.Replace(str,"{view\\s+(.+)}","<?php include view($1); ?>"); str=Regex.Replace(str,"{template\\s+(.+)}","<?php include template($1); ?>"); str=Regex.Replace(str,"{include\\s+(.+)}","<?php include $1; ?>"); str=Regex.Replace(str,"{view\\s+(.+)}","<?php include view($1); ?>"); str=Regex.Replace(str,"{template\\s+(.+)}","<?php include template($1); ?>"); str=Regex.Replace(str,"{include\\s+(.+)}","<?php include $1; ?>");

小旋风柴进 2019-12-02 01:58:49 0 浏览量 回答数 0

回答

#include <stdio.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <math.h> #define MM 7081 #define KK 1789 #define PHIM 6912 #define PP 85 typedef char strtype[10000]; int len; long nume[10000]; int change[126]; char antichange[37]; void initialize() { int i; char c; for (i = 11, c = 'A'; c <= 'Z'; c ++, i ++) { change[c] = i; antichange[i] = c; } } void changetonum(strtype str) { int l = strlen(str), i; len = 0; memset(nume, 0, sizeof(nume)); for (i = 0; i < l; i ++) { nume[len] = nume[len] * 100 + change[str[i]]; if (i % 2 == 1) len ++; } if (i % 2 != 0) len ++; } long binamod(long numb, long k) { if (k == 0) return 1; long curr = binamod (numb, k / 2); if (k % 2 == 0) return curr * curr % MM; else return (curr * curr) % MM * numb % MM; } long encode(long numb) { return binamod(numb, KK); } long decode(long numb) { return binamod(numb, PP); } main() { strtype str; int i, a1, a2; long curr; initialize(); puts("Input 'Y' if encoding, otherwise input 'N':"); gets(str); if (str[0] == 'Y') { gets(str); changetonum(str); printf("encoded: "); for (i = 0; i < len; i ++) { if (i) putchar('-'); printf(" %ld ", encode(nume[i])); } putchar('\n'); } else { scanf("%d", &len); for (i = 0; i < len; i ++) { scanf("%ld", &curr); curr = decode(curr); a1 = curr / 100; a2 = curr % 100; printf("decoded: "); if (a1 != 0) putchar(antichange[a1]); if (a2 != 0) putchar(antichange[a2]); } putchar('\n'); } putchar('\n'); system("PAUSE"); return 0; }

知与谁同 2019-12-02 01:26:51 0 浏览量 回答数 0

问题

C语言利用递归实现整数次幂出错

a123456678 2019-12-01 19:48:27 711 浏览量 回答数 1

问题

linux c语言 socket编程 recv每次收到一样的数据

杨冬芳 2019-12-01 20:21:47 1248 浏览量 回答数 1

问题

liunx下,文件的上传与下载?报错

爱吃鱼的程序员 2020-06-14 21:54:38 2 浏览量 回答数 1

问题

C++中类的使用,求助

a123456678 2019-12-01 20:06:24 1056 浏览量 回答数 1

回答

假设已经有一个kmp函数,返回substr在str中出现的位置,如果不存在则返回NULL(行为和strstr一样)。 #include <stdio.h> #include <string.h> #include <stdlib.h> const char *kmp(const char *str, const char *substr) { return strstr(str, substr); //kmp的实现略过 } void str_replace(char *dest, const char *src, const char *pattern, const char *replace) { int lp = strlen(pattern), lr = strlen(replace); const char *temp = src, *last = src; while ((temp = kmp(temp, pattern)) != NULL) { //copy to dest memcpy(dest, last, temp - last); dest += temp - last; strcpy(dest, replace); dest += lr; temp += lp; last = temp; } strcpy(dest, last); } int main() { char dest[1000]; str_replace(dest, "abcdefgabcdefgabcdefg", "fg", "----"); printf("%s\n", dest); str_replace(dest, "abcdefgabcdefgabcdefg", "ef", "----"); printf("%s\n", dest); str_replace(dest, "hello world", "l", "ab"); printf("%s\n", dest); return 0; } 算法其实挺简单,接口的设计,得写额外的代码来计算需要多大的空间,上面就略过了,另外附一个由函数负责分配空间的安全版(相应的后果是要额外扫一遍): #include <stdio.h> #include <string.h> #include <stdlib.h> const char *kmp(const char *str, const char *substr) { return strstr(str, substr); } char *str_replace(const char *src, const char *pattern, const char *replace) { int count = 0, lp = strlen(pattern), lr = strlen(replace); char *dest = NULL, *ret = NULL; const char *temp = src, *last = NULL; while ((temp = kmp(temp, pattern)) != NULL) { count++; temp += lp; } dest = ret = (char *)malloc(sizeof(lr - lp) * count + strlen(src) + 1); if (ret == NULL) return NULL; temp = src, last = src; while ((temp = kmp(temp, pattern)) != NULL) { //copy to dest memcpy(dest, last, temp - last); dest += temp - last; strcpy(dest, replace); dest += lr; temp += lp; last = temp; } strcpy(dest, last); return ret; } int main() { char *dest = NULL; dest = str_replace("abcdefgabcdefgabcdefg", "fg", "----"); if (dest != NULL) printf("%s\n", dest); free(dest); dest = str_replace("abcdefgabcdefgabcdefg", "ef", "----"); if (dest != NULL) printf("%s\n", dest); free(dest); dest = str_replace("hello world", "l", "ab"); if (dest != NULL) printf("%s\n", dest); free(dest); return 0; }

杨冬芳 2019-12-02 02:23:23 0 浏览量 回答数 0

问题

system()函数为什么在这里会出错呢?望大神指点

a123456678 2019-12-01 20:06:47 1156 浏览量 回答数 0

问题

关于STL vector的遍历问题,请问怎样一边操作一边遍历删除?

a123456678 2019-12-01 20:11:11 1417 浏览量 回答数 1

回答

1,前端和后端之间约定的信息应该是PageSize、PageNum。2,后端在分页之前先查询一把数据总数。3,基于数据总数、PageSize以及PageNum就可以计算出MySQL中需要的Limit和OffSet值。 代码示例:一,查询基类package com.freedom.dal.common; /** 分页查询的基类 */ class QueryBase { //数据总量 private Integer totalSize; //每页大小 private Integer pageSize; //当前页数 private Integer currentPage; // for paging private int startRow; private int endRow; protected Integer getDefaultPageSize() { return defaultPageSize; } public boolean isFirstPage() { return this.getCurrentPage().intValue() == 1; } public int getPreviousPage() { int back = this.getCurrentPage().intValue() - 1; if (back <= 0) { back = 1; } return back; } public boolean isLastPage() { return this.getTotalPage() == this.getCurrentPage().intValue(); } public int getNextPage() { int back = this.getCurrentPage().intValue() + 1; if (back > this.getTotalPage()) { back = this.getTotalPage(); } return back; } public Integer getCurrentPage() { if (currentPage == null) { return defaultFristPage; } return currentPage; } public void setCurrentPageString(String pageString) { if (isBlankString(pageString)) { this.setCurrentPage(defaultFristPage); } try { Integer integer = new Integer(pageString); this.setCurrentPage(integer); } catch (NumberFormatException ignore) { this.setCurrentPage(defaultFristPage); } } public void setCurrentPage(Integer cPage) { if ((cPage == null) || (cPage.intValue() <= 0)) { this.currentPage = null; } else { this.currentPage = cPage; } setStartEndRow(); } private void setStartEndRow() { this.startRow = this.getPageSize().intValue() * (this.getCurrentPage().intValue() - 1) + 1; this.endRow = this.startRow + this.getPageSize().intValue() - 1; } public Integer getPageSize() { if (pageSize == null) { return getDefaultPageSize(); } return pageSize; } public boolean hasSetPageSize() { return pageSize != null; } public void setPageSizeString(String pageSizeString) { if (isBlankString(pageSizeString)) { return; } try { Integer integer = new Integer(pageSizeString); this.setPageSize(integer); } catch (NumberFormatException ignore) { } } private boolean isBlankString(String pageSizeString) { if (pageSizeString == null) { return true; } if (pageSizeString.trim().length() == 0) { return true; } return false; } public void setPageSize(Integer pSize) { if ((pSize == null) || (pSize.intValue() <= 0)) { this.pageSize = null; } else { this.pageSize = pSize; } setStartEndRow(); } public Integer getTotalItem() { if (totalSize == null) { return defaultTotleItem; } return totalSize; } public void setTotalItem(Integer tItem) { if (tItem == null) { throw new IllegalArgumentException("TotalItem can't be null."); } this.totalSize = tItem; int current = this.getCurrentPage().intValue(); int lastPage = this.getTotalPage(); if (current > lastPage) { this.setCurrentPage(new Integer(lastPage)); } } public int getTotalPage() { int pgSize = this.getPageSize().intValue(); int total = this.getTotalItem().intValue(); int result = total / pgSize; if ((total == 0) || ((total % pgSize) != 0)) { result++; } return result; } public int getPageFristItem() { int cPage = this.getCurrentPage().intValue(); if (cPage == 1) { return 1; } cPage--; int pgSize = this.getPageSize().intValue(); return (pgSize * cPage) + 1; } public int getPageLastItem() { int cPage = this.getCurrentPage().intValue(); int pgSize = this.getPageSize().intValue(); int assumeLast = pgSize * cPage; int totalItem = getTotalItem().intValue(); if (assumeLast > totalItem) { return totalItem; } else { return assumeLast; } } public int getEndRow() { return endRow; } public void setEndRow(int endRow) { this.endRow = endRow; } public int getStartRow() { return startRow; } public void setStartRow(int startRow) { this.startRow = startRow; } protected String getSQLBlurValue(String value) { if (value == null) { return null; } return value + '%'; } public boolean nextPage() { if(this.currentPage != null && this.currentPage.intValue() >= this.getTotalPage()) return false; if(this.currentPage == null) { this.setCurrentPage(defaultFristPage); } else { this.setCurrentPage(getNextPage()); } return true; } public int getStart() { int startRow = getStartRow() - 1; return startRow > 0 ? startRow : 0; }} 二,DAO中基本逻辑1,生成查询基类,并将前端传递过来的pageSize和pageNum设置给查询基类。2,查询数据总量,将数据总量设置到查询基类中。3,查询。 三,xml配置SELECT <include refid="ConfigDOColums"></include> FROM CONFIGS WHERE <include refid="configQueryConditions"></include> LIMIT #{start}, #{pageSize}

断桥梅 2019-12-02 02:13:34 0 浏览量 回答数 0

回答

为了执行这个任务,我们必须创建半透明的背景,我们通过激活属性Qt::WA_TranslucentBackground来实现,然后我们使用QPainterPath来绘制矩形减去透明圆。 然后使用eventFilter来了解一些事件,比如当您更改大小或位置时显示的事件。 然后创建一个结构来存储数据,在本例中是圆的中心、半径、文本的位置和文本本身。 然后添加next和return按钮,并在插槽中处理页面更改的逻辑。 tutowidget.h #ifndef TUTOWIDGET_H #define TUTOWIDGET_H #include <QWidget> class QButtonGroup; class TutoWidget : public QWidget { Q_OBJECT struct Pages{ QPoint center; int radius; QPoint pText; QString text; }; public: TutoWidget(QWidget *parent); void addPage(const QPoint &center, int radius, const QPoint &pText, const QString & text); bool eventFilter(QObject *watched, QEvent *event); protected: void paintEvent(QPaintEvent *); private slots: void onClicked(int id); private: QWidget *mParent; QButtonGroup *group; QVector<Pages> pages; int currentIndex = -1; }; #endif // TUTOWIDGET_H tutowidget.cpp #include "tutowidget.h" #include <QVBoxLayout> #include <QButtonGroup> #include <QPushButton> #include <QEvent> #include <QTimer> #include <QPainter> TutoWidget::TutoWidget(QWidget *parent):QWidget(0) { setWindowFlags(Qt::FramelessWindowHint|Qt::Popup); setAttribute(Qt::WA_TranslucentBackground, true); mParent = parent; mParent->installEventFilter(this); QVBoxLayout *vlay = new QVBoxLayout(this); vlay->addItem(new QSpacerItem(20, 243, QSizePolicy::Minimum, QSizePolicy::Expanding)); QHBoxLayout *hlay = new QHBoxLayout; vlay->addLayout(hlay); group = new QButtonGroup(this); const QStringList nameBtns{"Return", "Next"}; for(int i=0; i < nameBtns.length(); i++){ QPushButton* btn = new QPushButton(nameBtns[i]); btn->setFlat(true); group->addButton(btn, i); hlay->addWidget(btn); } connect(group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, static_cast<void (TutoWidget::*)(int)>(&TutoWidget::onClicked)); hlay->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); group->button(0)->hide(); } void TutoWidget::addPage(const QPoint &center, int radius, const QPoint &pText, const QString &text) { pages << Pages{center, radius, pText, text}; if(currentIndex == -1){ currentIndex = 0; update(); } } bool TutoWidget::eventFilter(QObject *watched, QEvent *event){ if(watched == mParent){ switch (event->type()) { case QEvent::Show: QTimer::singleShot(10, this, &QWidget::show); break; case QEvent::Close: close(); break; case QEvent::Move: move(mParent->mapToGlobal(QPoint(0, 0))); break; case QEvent::Resize: resize(mParent->size()); break; default: break; } } return QWidget::eventFilter(watched, event); } void TutoWidget::paintEvent(QPaintEvent *){ QPainter painter(this); painter.setPen(Qt::NoPen); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(QColor(100, 100, 100, 200)); QPainterPath path; if(currentIndex != -1){ QPoint center = pages[currentIndex].center; int radius = pages[currentIndex].radius; QString text = pages[currentIndex].text; QPoint pText = pages[currentIndex].pText; path.moveTo(center + radius/2*QPoint(1, 0)); path.arcTo(QRect(center-radius/2*QPoint(1, 1),radius*QSize(1, 1)), 0, 360); path.addText(pText, font(), text); } path.addRect(rect()); painter.drawPath(path); } void TutoWidget::onClicked(int id) { if(id == 0){ if(currentIndex > 0) currentIndex--; } else if(id == 1){ if(currentIndex < pages.count()-1) currentIndex++; } update(); group->button(0)->setVisible(currentIndex!=0); group->button(1)->setVisible(currentIndex!=(pages.count()-1)); } 例子: tuto = new TutoWidget(this); // this is the widget tuto->addPage(QPoint(200, 200), 40, QPoint(100, 100), "some text1"); tuto->addPage(QPoint(300, 300), 60, QPoint(200, 100), "some text2"); tuto->addPage(QPoint(100, 200), 100, QPoint(200, 50), "some text3"); tuto->addPage(QPoint(200, 100), 80, QPoint(100, 200), "some text4"); 完整的示例在下面的链接中

kun坤 2019-12-28 14:25:19 0 浏览量 回答数 0

回答

#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #define CHILD_SIZE 5 #define BUF_SIZE 100 static void child_process(); int main() { int num_child = 0; pid_t pid; char buf[100]; int count = 0; int n; while(1) { while (num_child < CHILD_SIZE && count < 20) { pid = fork(); if (pid == 0) { child_process(); } else if (pid < 0) { write(1, "ERR: fork()\n", sizeof("ERR: fork()\n")-1); break; } else { n = snprintf(buf, BUF_SIZE, "Process %d Created.\n", pid); write(1, buf, n); } num_child++; count++; } pid = wait(NULL); if (pid == -1) break; n = snprintf(buf, BUF_SIZE, "Process %d End.\n", pid); write(1, buf, n); num_child--; } return 0; } static void child_process() { sleep(random()%5); exit(0); }

a123456678 2019-12-02 02:46:17 0 浏览量 回答数 0
阿里云大学 云服务器ECS com域名 网站域名whois查询 开发者平台 小程序定制 小程序开发 国内短信套餐包 开发者技术与产品 云数据库 图像识别 开发者问答 阿里云建站 阿里云备案 云市场 万网 阿里云帮助文档 免费套餐 开发者工具 企业信息查询 小程序开发制作 视频内容分析 企业网站制作 视频集锦 代理记账服务 2020阿里巴巴研发效能峰会 企业建站模板 云效成长地图 高端建站 阿里云双十一主会场 阿里云双十一新人会场 1024程序员加油包 阿里云双十一拼团会场 场景化解决方案 阿里云双十一直播大厅