C语言经典编程题--哥德巴赫猜想 、完数 、猜数字等

  一、  验证歌德巴赫猜想:任意一个不小于6的偶数都可以表示成两个素数的和。从键盘任意给一个符合条件的数,输出相应的两个素数。

素数:指在一个大于1的自然数中,除了1和此整数自身外,没法被其他自然数整除的数

代码如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2. #include <math.h>  
  3.   
  4. int sushu(int n)  
  5. {  
  6.     int i,j;  
  7.     for(i = 2;i <= sqrt(n + 1);i++)  
  8.     {  
  9.         if(!(n%i))  
  10.             return 0;  
  11.         break;  
  12.     }  
  13.     return 1;  
  14. }  
  15.   
  16. int main()  
  17. {  
  18.     int a,b,N;  
  19.     int i;  
  20.     printf("Please input a number N: N >= 6 && N%2==0\n");  
  21.     scanf("%d",&N);  
  22.     if((N < 6) || (N & 1))  
  23.     {  
  24.         printf("Please input a correct number!\n");  
  25.         return 0;  
  26.     }  
  27.     else  
  28.     {  
  29.         for(i = 2;i <= N/2;i++)  
  30.         {  
  31.             if(sushu(i) && sushu(N -i))  
  32.                 printf("%d = %d + %d\n",N,i,N-i);  
  33.             break;        
  34.         }  
  35.           
  36.     }  
  37.     return 0;  
  38. }  

判定一个数是否为素数的简单方法:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int sushu(int n)  
  4. {  
  5.     int i,j;  
  6.     for(i = 2;i <= sqrt (n + 1);i++)  
  7.     {  
  8.         if(!(n%i))  
  9.             return 0;  
  10.     }  
  11.     return 1;  
  12. }  

二、完数问题:

题目:一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3.编程
    找出1000以内的所有完数。

代码如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int Sum(int n)  
  4. {  
  5.     int i;  
  6.     int sum = 0;  
  7.     for(i = 1;i < n;i++)  
  8.     {  
  9.         if(!(n%i))   
  10.             sum += i;  
  11.     }  
  12.     return sum;  
  13. }  
  14.   
  15. int main()  
  16. {  
  17.     int j;  
  18.     for(j = 2;j < 1000;j++)  
  19.     {  
  20.         if(Sum(j) == j)  
  21.             printf("%d is a wanshu!\n",j);  
  22.     }  
  23.     return 0;  
  24. }  


 三、题目:猜数字游戏

需求定义:

编写程序,实现控制台的猜数字游戏。游戏运行时产生一个0100之间的随机整数,要求用户从控制台输入数字,若输入的数字比产生的数字小,则输出:“太小了,再大一点!”;若输入的数字比产生的数字大,则输出:“太大了,再小一点!”,若输入的数字和产生的数字相等,则输出:“恭喜你猜对了!”然后退出程序;若用户猜了10次还未猜对,则输出:“你太笨了,下次再来吧!”然后退出程序。

程序如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2. #include <stdio.h>  
  3.   
  4. int main()  
  5. {  
  6.     int n,m;  
  7.     int count = 0;  
  8.     srand((unsigned int)time(NULL));  
  9.     n = rand();  
  10.     n %= 100;  
  11.     while(count < 10)  
  12.     {  
  13.         printf("Please input a number:\n");  
  14.         scanf("%d",&m);  
  15.         if(m == n)  
  16.         {  
  17.             printf("You are right!\n");  
  18.             return 0;  
  19.         }  
  20.         else if(m < n)  
  21.         {  
  22.             printf("Too small !Please bigger!\n");  
  23.             count++;  
  24.         }  
  25.         else  
  26.         {  
  27.             printf("Too big!Please smaller!\n");  
  28.             count++;  
  29.         }  
  30.     }  
  31.         printf("You are stupid!Next!\n");  
  32.         printf("This num is %d",n);  
  33.         return 1;  
  34.       
  35. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/caishuzi$ ./caishuzi  
  2. Please input a number:  
  3. 50  
  4. Too big!Please smaller!  
  5. Please input a number:  
  6. 25  
  7. Too small !Please bigger!  
  8. Please input a number:  
  9. 37  
  10. Too small !Please bigger!  
  11. Please input a number:  
  12. 43  
  13. Too big!Please smaller!  
  14. Please input a number:  
  15. 40  
  16. Too big!Please smaller!  
  17. Please input a number:  
  18. 39  
  19. You are right!  


 这里有个函数,产生一个随机数,大家可以记一下

[cpp] view plaincopy
  1. srand((unsigned int)time(NULL));    
  2. n = rand();    

实际产生的数可能会很大,这里可以 n %=100,生成的数就是1~100之内的数了,可能不符合规范,但可以达到目的!

四、题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。
程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成: 
(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。
(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,
  重复执行第一步。
(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步

执行程序:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     int i,n;  
  6.     printf("Please input a num:\n");  
  7.     scanf("%d",&n);  
  8.     printf("%d = ",n);  
  9.     for(i = 2;i <= n;i++)  
  10.     {  
  11.         while(n != i)  
  12.         {  
  13.             if(n%i == 0)  
  14.             {  
  15.                 printf("%d*",i);  
  16.                 n = n/i;  
  17.             }  
  18.             else  
  19.                 break;  
  20.         }  
  21.     }  
  22. printf("%d\n",n);  
  23. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/14$ ./14  
  2. Please input a num:  
  3. 9  
  4. 9 = 3*3  
  5. fs@ubuntu:~/qiang/14$ ./14  
  6. Please input a num:  
  7. 36  
  8. 36 = 2*2*3*3  
  9. fs@ubuntu:~/qiang/14$   

 

五、题目:写一个函数,统计一个int型数据中有多少位为1;

程序分析:我们知道,如果判定某位是否为1的方法,一个整型数据有多少位为1,可以对此数据进行移位操作,然后判定最后一位是否为1,代码如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     int n,count = 0;  
  6.     int i;  
  7.     printf("Please input a num:\n");  
  8.     scanf("%d",&n);  
  9.   
  10.     for(i = 0; i < 32;i++)  
  11.     {  
  12.         if(n & 0x01)  
  13.         {  
  14.             count++;  
  15.         }  
  16.   
  17.         n >>= 1;  
  18.     }  
  19.       
  20.     printf("Total 1 = %d\n",count);  
  21. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/int$ ./3  
  2. Please input a num:  
  3. 8  
  4. Total 1 = 1  
  5. fs@ubuntu:~/qiang/int$ ./3  
  6. Please input a num:  
  7. 15  
  8. Total 1 = 4  
  9. fs@ubuntu:~/qiang/int$   


六、鞍点问题

题目:有一个3X4矩阵,要求输出其鞍点(行列均最大的值),以及它的行号和列号。

int a[3][4] = {{123,94,-10,218},

                         {3,9,10,-83},

                          {145,16,44,-99}

                         };

程序分析:首先要搞明白鞍点不止一个,这题肯定涉及到对二维数据的遍历,然后比较大小,先找出当前行最大值,然后判定其在当前列是否为最大值,如果是,则输出
 代码如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     int a[3][4] ={  
  6.             {123,94,-10,218},  
  7.             {3,9,10,-83},  
  8.             {145,16,44,-99}  
  9.             };  
  10.   
  11.     int i,j,k;  
  12.     char flag,flag1;  
  13.     for(i = 0; i < 3; i++ )  
  14.     {  
  15.         for(j = 0; j < 4; j++)  
  16.         {  
  17.             flag = 0;  
  18.             flag1 = 0;  
  19.             for(k = 0 ;k < 4;k++)  
  20.             {  
  21.                 if(a[i][j] < a[i][k])//当前行是否最大  
  22.                     flag = 1;  
  23.             }  
  24.             for(k = 0 ;k < 3;k++)  
  25.             {  
  26.                 if(a[i][j] < a[k][j])//当前列是否最大  
  27.                     flag1 = 1;  
  28.             }  
  29.             if(!flag && !flag1)//当前行当前列是否都是最大  
  30.                 printf("hang:%d lie:%d = %d\n",i,j,a[i][j]);  
  31.         }  
  32.     }  
  33.     return 0;  
  34. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/andian$ ./andian  
  2. hang:0 lie:3 = 218  
  3. hang:2 lie:0 = 145  
  4. fs@ubuntu:~/qiang/andian$   

 

七、题目、数组归并

已知两个升序数组a、b及空数组c:

int a[] = {1,3,5,7,9,11,13,15,17,19};

int b[] = {2,4,6,8,10,12,14,16,18,20};

int c[20] ;

编写程序将两个数组完成归并,并存入数组c中;

 

[cpp] view plaincopy
  1. #include <stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     int a[] = {1,3,5,7,9,11,13,15,17,19};  
  6.     int b[] = {2,4,6,8,10,12,14,16,18,20};  
  7.     int c[20];  
  8.   
  9.     int i, j, k;  
  10.      i = j = k = 0;  
  11.     while(i < 10 && j < 10)  
  12.     {  
  13.         if(a[i] > b[j])  
  14.             c[k++] = b[j++];  
  15.         else  
  16.             c[k++] = a[i++];  
  17.     }  
  18.     while(i < 10)  
  19.         c[k++] = a[i++];  
  20.     while(j < 10)  
  21.         c[k++] = b[j++];  
  22.   
  23.     printf("c[] = ");  
  24.     for(k = 0;k< 20;k++)  
  25.         printf("%d ",c[k]);  
  26.   
  27.     printf("\n");  
  28.   
  29.     return 0;  
  30. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/shuzu$ gcc -o shuzu7 shuzu7.c  
  2. fs@ubuntu:~/qiang/shuzu$ ./shuzu7  
  3. c[] = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20   
  4. fs@ubuntu:~/qiang/shuzu$   

 

八、指针输入一个字符串,内有数字和非数字字符,如a123X456  17960? 302tab5876 将其中连续的数字作为一个整数,一次存放到整数型数组a中,例如123放到 a[0],456放到 a[1]中,统计有多少个整数,并输出这些数;

代码如下:

[cpp] view plaincopy
  1. <pre name="code" class="cpp">#include <stdio.h>  
  2. #include <string.h>  
  3.   
  4. int main(int argc, const char *argv[])  
  5. {  
  6.     char b[100];  
  7.     int  a[100];  
  8.     memset(a,'\0',100);  
  9.     char *p = b;  
  10.     int i = 0;  
  11.     int j;  
  12.     int sum = 0;  
  13.     int count = 0;  
  14.     int flag = 1;//标志位,遇到数字为0,遇到非数字为1;此处其初始值为1,默认首字符前面还是非数字,不输出整数,主要配合下面的程序  
  15.     printf("请输入字符串:\n");  
  16.     gets(b);  
  17.       
  18.     while(*p )  
  19.     {  
  20.         if(*p <= '9' && *p >= '0')  
  21.         {  
  22.             flag = 0;//遇到数字,flag=0  
  23.             sum = sum*10 + *p++ - '0';//将字符数字转化成整数,此时并不输出。当下一个字符为非数字时,才输出  
  24.         }     
  25.         else   
  26.         {  
  27.             while(flag == 0)//此时读到非数字字符,判断此时flag,如果此时flag为0.说明上一个字符为数字  
  28.             {  
  29.                 a[i++] = sum ;//此时将数字输出,赋给a[i],i++  
  30.                 sum = 0;//将sum清零  
  31.                 flag = 1;//非数字字符,flag置1  
  32.             }  
  33.             p++;//此时flag为1,没有整数输出,则看下一个字符  
  34.         }  
  35.     }  
  36. //字符串结束后,会遇到两种情况,一个是最后一个字符为数字,另一种是非数字字符  
  37.     if(flag == 0)//因为前面的程序中,整数的下一个字符为非数字时,才会输出整数,若最后一个是数字的话,则无法输出,所以这里对最后一个字符进行判断  
  38.         a[i] = sum;//将最后一个整数输出  
  39.     else   
  40.         i--;//此时最后一个字符为非数字,没有整数输出,但i多加了一次,所以此处i--  
  41.       
  42.     count = i + 1;//整数个数为i+1  
  43.     printf("共有%d个整数\n",count);  
  44.     printf("这些整数是:\na[]=");  
  45.     for(j = 0; j < i+1; j++)  
  46.         printf("%d ",a[j]);  
  47.     printf("\n");  
  48.   
  49.     return 0;  
  50. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/tmp$ ./zhizhen1  
  2. 请输入字符串:  
  3. 123xiao45  ?<er97  
  4. 共有3个整数  
  5. 这些整数是:  
  6. a[]=123 45 97   
  7. fs@ubuntu:~/qiang/tmp$ ./zhizhen1  
  8. 请输入字符串:  
  9. xiao12jian5w4gd67dd  
  10. 共有4个整数  
  11. 这些整数是:  
  12. a[]=12 5 4 67   
  13. fs@ubuntu:~/qiang/tmp$   

九、链表问题

创建一个单向链表,实现一个简单的学生成绩统计系统

代码如下:

[cpp] view plaincopy
  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3. #include <malloc.h>  
  4. #include <string.h>  
  5. #define DEBUG() printf("%s %s %d\n",__FILE__,__FUNCTION__,__LINE__)  
  6.   
  7. typedef struct grade  
  8. {  
  9.     int  score;  
  10.     char name[10];  
  11.     struct grade *next;  
  12. }Node;  
  13.   
  14. Node *CreateList()  
  15. {  
  16.     Node *p,*head,*tail;  
  17.     head = (Node *)malloc(sizeof(Node));  
  18.     if(head == NULL)  
  19.     {  
  20.         printf("malloc fails!\n");  
  21.         return 0;  
  22.     }  
  23.     head->next = NULL;  
  24.     tail = head;  
  25.   
  26.     int i = 0;  
  27.     while(1)  
  28.     {  
  29.         int  s;   
  30.         char n[10];  
  31.         printf("Please input the student's name!\n");  
  32.         gets(n);  
  33.         printf("Please input the student's score!\n");  
  34.         scanf("%d",&s);  
  35.         getchar();  
  36.         if( s )  
  37.         {  
  38.             p = (Node *)malloc(sizeof(Node));  
  39.             if(p == NULL)  
  40.             {  
  41.                 printf("malloc fails!\n");  
  42.                 return 0;  
  43.             }  
  44.             p->score = s;  
  45.             strcpy(p->name,n);  
  46.             p->next = NULL;  
  47.             printf("name:%s score:%d\n",p->name,p->score);  
  48.   
  49.             tail->next = p;  
  50.             tail = p;  
  51.         }  
  52.         else  
  53.         {     
  54.             return head;  
  55.         }  
  56.     }  
  57. }  
  58.   
  59. DisplayList(Node *pnode)  
  60. {  
  61.     pnode = pnode->next;  
  62.     while ( pnode )  
  63.     {  
  64.         printf("name:%-6s score:%d\n",pnode->name,pnode->score);  
  65.         pnode = pnode->next;  
  66.     }  
  67. }  
  68.   
  69. LookupList(Node *p)  
  70. {  
  71.     char n[10];  
  72.     char *t = n;  
  73.     printf("Please input the name you want:\n");  
  74.     gets(n);  
  75.     p = p->next;  
  76.     while( p != NULL)  
  77.     {  
  78.         if (!strcmp(p->name,t))  
  79.         {  
  80.             printf("%s' score is: %d\n",t,p->score);  
  81.             return 0;  
  82.         }  
  83.         else  
  84.             p = p->next;  
  85.     }  
  86.     printf("%s is not exeit!Please input the correct name\n",t);  
  87. }  
  88.   
  89. DestroyList(Node *p)  
  90. {  
  91.     Node *q;  
  92.     if(p->next != NULL)  
  93.     {  
  94.         q = p;  
  95.         p = p->next;  
  96.         free(q);  
  97.         q = NULL;  
  98.     }  
  99. }  
  100.   
  101. InsertList(Node *p)  
  102. {  
  103.     char n[10];  
  104.     char *t = n;  
  105.     printf("Please input the name you want to insert after:\n");  
  106.     gets(n);  
  107.     p = p->next;  
  108.     while( p != NULL)  
  109.     {  
  110.         if (!strcmp(p->name,t))  
  111.         {  
  112.             int  s;   
  113.             char m[10];  
  114.             printf("Please input the student's name!\n");  
  115.             gets(m);  
  116.             printf("Please input the student's score!\n");  
  117.             scanf("%d",&s);  
  118.             getchar();  
  119.             Node *q;  
  120.             q = (Node *)malloc(sizeof(Node));  
  121.             strcpy(q->name,m);  
  122.             q->score = s;  
  123.             q->next = p->next;  
  124.             p->next = q;  
  125.               
  126.             return 0;  
  127.         }  
  128.         else  
  129.             p = p->next;  
  130.     }  
  131. }  
  132.   
  133. int main()  
  134. {  
  135.     Node *p1;  
  136.     p1 = CreateList();  
  137.     DisplayList(p1);  
  138.     LookupList(p1);  
  139.     InsertList(p1);  
  140.     DisplayList(p1);  
  141.     DestroyList(p1);  
  142.   
  143.     return 0;  
  144. }  

执行结果如下:

[cpp] view plaincopy
  1. fs@ubuntu:~/qiang/link$ ./link2  
  2. Please input the student's name!  
  3. xiao  
  4. Please input the student's score!  
  5. 100  
  6. name:xiao score:100  
  7. Please input the student's name!  
  8. zhi   
  9. Please input the student's score!  
  10. 85  
  11. name:zhi score:85  
  12. Please input the student's name!  
  13. qiang  
  14. Please input the student's score!  
  15. 88  
  16. name:qiang score:88  
  17. Please input the student's name!  
  18. ming  
  19. Please input the student's score!  
  20. 77  
  21. name:ming score:77  
  22. Please input the student's name!  
  23. hui  
  24. Please input the student's score!  
  25. 78  
  26. name:hui score:78  
  27. Please input the student's name!  
  28. null  
  29. Please input the student's score!  
  30. 0  
  31. name:xiao   score:100  
  32. name:zhi    score:85  
  33. name:qiang  score:88  
  34. name:ming   score:77  
  35. name:hui    score:78  
  36. Please input the name you want:  
  37. qiang   
  38. qiang' score is: 88  
  39. Please input the name you want to insert after:  
  40. ming  
  41. Please input the student's name!  
  42. fang  
  43. Please input the student's score!  
  44. 92  
  45. name:xiao   score:100  
  46. name:zhi    score:85  
  47. name:qiang  score:88  
  48. name:ming   score:77  
  49. name:fang   score:92  
  50. name:hui    score:78  
  51. fs@ubuntu:~/qiang/link$   

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/402517.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Calendar的DAY_OF_MONTH, DAY_OF_YEAR, DATE的区别

From: https://blog.csdn.net/weixin_34233679/article/details/87286628 cal1.add(Calendar.DAY_OF_MONTH,1); cal1.add(Calendar.DAY_OF_YEAR,1); cal1.add(Calendar.DATE,1); 就单纯的add操作结果都一样&#xff0c;因为都是将日期1 就没有区别说是在月的日期中加1还是…

Cisco网络防火墙配置方法

这篇文章主要介绍了Cisco网络防火墙配置方法,需要的朋友可以参考下  由于网络防火墙默认禁止所有的通信&#xff0c;因为&#xff0c;只有对其进行适当配置后&#xff0c;才能实现正常的网络通信。  如何配置Cisco网络防火墙  1.进入全局配置模式  ciscoasa#configure …

linux远程登录三种方式telnet,ssh,vnc

linux远程连接三种方式telnet&#xff0c;ssh&#xff0c;vnctelnet和ssh服务只能实现基于字符界面的远程控制&#xff0c;如果要基于图形界面进行远程控制&#xff0c;可以借助免费的VNC来完成。一、telnet连接1.首先进入终端&#xff0c;查看是否安装了telnet服务。linux默认…

老司机学习MyBatis之如何通过select返回Map

From: https://blog.csdn.net/Gaomb_1990/article/details/80638177 一、案例 当要查询的结果是一个Map的时候&#xff0c;这里分为两种情况&#xff1a; ①返回单条记录 <select id"getUserByIdReturnMap" resultType"map"> select id, log…

大数据之Yarn——Capacity调度器概念以及配置

试想一下&#xff0c;你现在所在的公司有一个hadoop的集群。但是A项目组经常做一些定时的BI报表&#xff0c;B项目组则经常使用一些软件做一些临时需求。那么他们肯定会遇到同时提交任务的场景&#xff0c;这个时候到底如何分配资源满足这两个任务呢&#xff1f;是先执行A的任务…

C#基于Socket的简单聊天室实践

序&#xff1a;实现一个基于Socket的简易的聊天室&#xff0c;实现的思路如下&#xff1a; 程序的结构&#xff1a;多个客户端一个服务端&#xff0c;客户端都是向服务端发送消息&#xff0c;然后服务端转发给所有的客户端&#xff0c;这样形成一个简单的聊天室功能。 实现的细…

C/C++经典面试题

面试题1&#xff1a;变量的声明和定义有什么区别 为变量分配地址和存储空间的称为定义&#xff0c;不分配地址的称为声明。一个变量可以在多个地方声明&#xff0c;但只能在一个地方定义。加入extern修饰的是变量的声明&#xff0c;说明此变量将在文件以外或在文件后面部分定义…

Java跳出多重循环

From: https://www.cnblogs.com/fastfn/p/9777067.html 场景&#xff1a;很多的时候需要做到跳出多重循环&#xff0c;而在Java中虽然后goto关键字&#xff0c;但是是保留字&#xff0c;并没有启用。而在处理分支结构的if...else,switch...case,好像都达不到想要的效果。 作为…

CCF 节日

问题描述有一类节日的日期并不是固定的&#xff0c;而是以“a月的第b个星期c”的形式定下来的&#xff0c;比如说母亲节就定为每年的五月的第二个星期日。现在&#xff0c;给你a&#xff0c;b&#xff0c;c和y1, y2(1850 ≤ y1, y2 ≤ 2050)&#xff0c;希望你输出从公元y1年到…

回文数算法

1、回文数&#xff1a;一种数字&#xff0c;如&#xff1a;12321, 这个数字正读是12321&#xff0c;倒读也是12321&#xff0c;即&#xff1a;将这个数的数字按相反的顺序重新排列后&#xff0c;所得到的数和原来的数一样。回文数判别算法&#xff08;java实现&#xff09;impo…

深入了解scanf() getchar()和gets()等函数之间的区别

----------------------------------------------------| 问题描述一&#xff1a;&#xff08;分析scanf()和getchar()读取字符&#xff09; |-------------------------------------------------- scanf(), getchar()等都是标准输入函数&#xff0c;一般人都会觉得这几个函数…

java基础集合简介Map(三)下

From: https://www.cnblogs.com/douyu2580860/p/8358768.html --Map接口简介 今天来看一看map集合&#xff0c;map映射接口&#xff0c;用于存放键值对&#xff0c;<key,value>&#xff0c;通过key来查找value,顾名思义key不能为空&#xff0c;唯一且不重复&#xff0c;不…

横向量与矩阵的乘积

设Tj(Tj1, Tj2, ..., Tjn)为横向量。而iδ是Tj中第δ位不为零的元素&#xff0c;1≤δ≤z。 令hjTjH, 则hj是TH的第j行。且有 hjΣ(ki1, i2, ..., iz)Tj,kHk. 从上式看&#xff0c; &#xff08;1&#xff09;可以将横向量的第k位视为右边矩阵第k行是否叠加的控制信号。 &#…

MySQL日期时间函数大全(转)

DAYOFWEEK(date) 返回日期date是星期几(1星期天,2星期一,……7星期六,ODBC标准)mysql> select DAYOFWEEK(1998-02-03);   -> 3 WEEKDAY(date)  返回日期date是星期几(0星期一,1星期二,……6 星期天)。 mysql> select WEEKDAY(1997-10-04 22:23:00);   -> 5 my…

C语言常见错误

对于刚学编程&#xff0c;刚接触C的新手来说&#xff0c;编译运行报错是最头疼的一件事&#xff0c;爆出一堆英文&#xff0c;英语差一点的又不知道什么意思&#xff0c;所以也不知道如何去改&#xff0c;在此&#xff0c;我给大家传一份常见错误中英文对照表及简单解释&#x…

screen 断开 screen -r 不能进入断开的会话

From: https://www.wrox.org/archives/541 screen意外断开后screen -r *** 命令不能进入断开的会话&#xff0c;出现如下提示&#xff1a; There is a screen on: 11103.*** (Attached) There is no screen to be resumed matching ***. 这个时候可以用下面这条命令进入&…

mysql数据迁移

[rootdns var]# service mysqld stop Shutting down MySQL.. [rootdns bin]# ./mysql_install_db --usermysql --datadir/data/mysql_data2转载于:https://blog.51cto.com/alwaysyunwei/1260567

从getmemery()函数看内存管理、函数传参等一系列问题

在C 面试题目中&#xff0c;会经常出现getmemery()函数的改错题&#xff0c;比如下面这道题&#xff0c; 例一&#xff1a;代码如下&#xff1a; [cpp] view plaincopy #include <stdio.h> char *getmemery() { char p[] "hello world!"; …

Java中array、List、Set互相转换

From: https://www.cnblogs.com/yysbolg/p/9977365.html 数组转List String[] staffs new String[]{"A", "B", "C"}; List staffsList Arrays.asList(staffs);//注意: Arrays.asList() 返回一个受指定数组决定的固定大小的列表。所以不能做 a…

Apache Shiro 使用手册(三)Shiro 授权

授权即访问控制&#xff0c;它将判断用户在应用程序中对资源是否拥有相应的访问权限。 如&#xff0c;判断一个用户有查看页面的权限&#xff0c;编辑数据的权限&#xff0c;拥有某一按钮的权限&#xff0c;以及是否拥有打印的权限等等。 一、授权的三要素授权有着三个核心元素…