-
Notifications
You must be signed in to change notification settings - Fork 0
/
scramble.cpp
73 lines (50 loc) · 1.1 KB
/
scramble.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<stdio.h>
#include<stdint.h>
bool scramble(const char *str1, const char *str2)
{
const char * p_str1 = str1;
while(*str2 != '\0')
{
p_str1 = str1;
while(*p_str1 != '\0')
{
if( *str2 == *p_str1)break;
p_str1++;
}
if(*p_str1 == '\0')return false;
str2++;
}
return true;
}
int main()
{
// if(scramble("katas", "codewars"))
// printf(" true\r\n");
// else
// printf(" false\r\n");
const int i =0;
int *p =(int *)&i;
*p =1;
printf("i=%d, *p =%d\r\n",i,*p);
printf("p=0x%08x,&i =0x%08x\r\n",p,&i);
float a[10] = {
10.05,
7.82,
10.32,
9.44,
9.72,
10.28,
9.26,
10.28,
9.7,
9.32
};
printf("sizeof(float) = %d\r\n",sizeof(float));
printf("sizeof( a[10])=%d\r\n", sizeof(a));
printf("a[%d]= 0x%08x\r\n",1, a[1]);
printf("a[%d]= 0x%08x\r\n",2, a[2]);
printf("a[%d]= 0x%08x\r\n",3, a[3]);
char *p_float =(char *) &a[1];
printf("0x%02x%02x%02x%02x",(uint8_t)*(p_float +3),(uint8_t)*(p_float +2),(uint8_t)*(p_float +1),(uint8_t)*p_float);
return 0;
}