摘要:
项目名称:多人聊天室项目结构: client.py server.py settings.py项目思路:服务端接收客户端连接,客户端发送信息给服务端,服务端将信息发送给所有客户端。项目实现:主进程负责接收键盘输入(sys.stdin.readline),使用multiprocessing.Proce 阅读全文
摘要:
在C中实现string字符串,使用typedef将string定义为char *。 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef char* string; string get_string(string); 阅读全文
摘要:
C getchar() #include <stdio.h> int main() { int size = 5; char str[size]; int now = 0; char ch; printf("Enter whatever you want: "); while ((ch = getc 阅读全文
摘要:
C++ 数组遍历的两种方式: #include <iostream> using namespace std; int main() { // 一维数组 int fibonacci[5] = {1, 1, 2, 3, 5}; // 使用索引遍历 // 求数组长度:sizeof(array)/size 阅读全文
摘要:
使用Java实现发红包的功能。 结构: package redPocket User.java Manager.java Member.java Demo.java 思路: Manager和Member类继承User,Manager类实现群主发红包的功能,Member类实现群员收红包的功能。Demo 阅读全文
摘要:
import java.util.Scanner; public class Factorial { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; while (true) { 阅读全文
摘要:
package main import "fmt" func f1() int { // 1、先执行返回值赋值,返回值等于x,等于5 // 2、执行defer语句,x++,x等于6 // 3、返回指令,返回返回值5 x := 5 defer func() { x++ // 修改的是x,不是返回值 }() return x } func f2() (x int) { // 1、先执行返回值赋值语句, 阅读全文
摘要:
#!/bin/bash # sum.sh # 获取随机数量的参数,相加并打印结果 # total=0 # # $# 表示参数的数量 # for 循环获取每个参数 # ${!i} 表示返回第i个参数 # for (( i = 1; i <= $#; i++ )) do total=$[ $total + ${!i} ] done # echo Total = $total # #!/bin/bash 阅读全文
摘要:
/* 一个统计字母(含大小写)出现次数的C程序 */ #include <stdio.h> int main() { char counts[52]; char ch; /* initialization */ for(int i = 0; i < sizeof(counts)/sizeof(cou 阅读全文
摘要:
/* linkedQueue.c */ /* 链队列 */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> /* 链队列数据结构 */ typedef struct node { int data; /* 节点存储数据 */ struct node *next; /* 指向下一个节点的指针 */ } Node; /* fron 阅读全文