所有栏目 | 云社区 美国云服务器[国内云主机商]
你的位置:首页 > 云社区 » 正文

编程题C语言?

发布时间:2020-04-15 16:11:26

资讯分类:c语言  编程  阶乘  我把  我要
编程题C语言?

呵呵,我把全部题合在一起写了,我把每个题目写成一个函数了,我标下吧

那个^是异或运算,就是二进制位相同的变为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 条评论)
   
验证码:
Top