留言与评论(共有 0 条评论) |
发布时间:2020-04-15 16:11:26
呵呵,我把全部题合在一起写了,我把每个题目写成一个函数了,我标下吧
那个^是异或运算,就是二进制位相同的变为0,不同的为1
举个例子:
a=1
b=8
现我要交换a和b
先转化为二进制:
a=0001
b=1000
a=a^b=0001^1000=1001
b=a^b=1001^1000=0001
a=a^b=1001^0001=1000
这样就调换了a和b了
你也可以用临时变量的
int temp;
temp=a;
a=b;
b=temp;
#include <stdio.h>
#include <string.h>
int Factorial(int n);//阶乘
void Sorting(int *p);//排序
void Reverse(char *p);//字符串逆转
int Statistics(char *p,char ch);//统计字母个数
main()
{
//阶乘
int N;
scanf("%d
留言与评论(共有 0 条评论) |
全站搜索