把一个100以内的自然数分解因数。大小端的判断。

写一个程序,把一个100以内的自然数分解因数。(自然数分解因数就是将一个自然数分解为几个素数的乘积,提示,由于该数不是很大,所以可以将质数保存在数组中,以加快计算速度)

 1 #include<stdio.h>
 2 #include<math.h>
 3 int Count(int n)
 4 {
 5  int i = 2;
 6  for(i = 2;i<=sqrt(n);i++)
 7  {
 8   if(n%i==0)
 9   {
10    printf("%d*",i);
11    return Count(n/=i);
12    break;
13   }
14  }
15  return printf("%d\n",n);
16 }
17 int main()
18 {
19  int num;
20  while(scanf("%d",&num)!=EOF)
21   Count(num);
22  return 0;
23 }

.大端和小端的区分

unsigned  int  Value = 0x12345678;
unsigned  char  buff[4];
 
小端:低地址:     buff[0] = 0x78;
                            buff[1] = 0x56; 
                            buff[2] = 0x34; 
          高地址:     buff[3] = 0x12; 
 
大端: 低地址: buff[0] = 0x12;
                         buff[1] = 0x34;
                         buff[2] = 0x56; 
           高地址: buff[3] = 0x78;
如何检测计算机是大端还是小端?
 1 #include <stdio.h>
 2 typedef union Type{
 3  int a;
 4  char b;
 5 }tmpType;
 6 int main(int argc, const char *argv[])
 7 {
 8  tmpType tmp;
 9  tmp.b = 1;
10  if(tmp.a == 1)
11   printf("little endian\n");
12  else
13   printf("big endian\n");
14  return 0;
15 }

 

转载于:https://www.cnblogs.com/youthshouting/p/4280538.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值