天天看點

神州數位c語言筆試題,神州數位筆試題,神州數位筆試題.doc

1、把字元串轉化成整形,不能用系統函數。 2、SQL 題(略) 3、24個人,要求5個人一排,排6排如何排? 4、8個人跑步比賽結果,給出系列條件:那個排名在那個前面、有一個第4名…… ,讓你推測出實際的名次。(略) 5、兩根蠟燭,每根單獨燃燒一個小時燃盡。如何通過兩根蠟燭的燃燒判斷45 分鐘?

(一)設計一個Windows下的C語言的,基于TCP的多線程伺服器和用戶端發送程式。1,對伺服器程式,伺服器收到用戶端發出的字元串後用printf()語句顯示出來,要求對用戶端封包的處理采用多線程并發處理方式;2,對于用戶端程式,用戶端收到來自鍵盤輸入的字元,然後發給指定IP的伺服器上。答案://==========================================================================//Server//==========================================================================#include #include #define BUFFER_SIZE牋?500#define MAX_CONNECTION_COUNTFD_SETSIZEint do_something_with(SOCKET NewConnection);void main(int argc, char *argv[]){WSADATA牋牋? 牋牋牋牋 wsaData;SOCKET牋牋牋牋牋牋牋 ListeningSocket;SOCKET牋牋牋牋牋牋牋 NewConnection[MAX_CONNECTION_COUNT];SOCKADDR_IN牋牋牋牋?ServerAddr;SOCKADDR_IN牋牋牋牋?ClientAddr;int牋牋牋牋牋牋牋牋?ClientAddrLen;u_short牋牋牋牋牋牋?Port = 5150;int牋? 牋牋牋牋牋牋牋 Ret;fd_set fdread;int i;// Initialize Winsock version 2.2if ((Ret = WSAStartup(MAKEWORD(2,2), &wsaData)) != 0){// NOTE: Since Winsock failed to load we cannot use WSAGetLastError // to determine the error code as is normally done wh en a Winsock // API fails. We have to report the return status of the function.printf("WSAStartup failed with error %d\n", Ret);return;}牋 for( i = 0;i < MAX_CONNECTION_COUNT; i++)NewConnection[i] = -1;// Cre ate a new socket to listening for client connections.if ((ListeningSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET){sockerror("Create socket failed! ");WSACleanup();return;} // Setup a SOCKADDR_IN structure that will tell bind that we// want to listen for connections on all interfaces using port// 5150. Notice how we convert the Port variable from host byte// order to network byte order.ServerAddr.sin_family = AF_INET;ServerAddr.sin_port = htons(Port);牋?ServerAddr.sin _addr.s_addr = htonl(INADDR_ANY);// Associate the add