1、#include<stdio.h>
int main()
{
int arr1[] = {1,2,3,4,5};
int arr2[] = {6,7,8,9,0};
int sz = sizeof(arr1)/sizeof(arr2);
int tmp = 0;
int i = 0;
for(i = 0; i < sz; i++)
{
tmp = arr1[i];
arr1[i] = arr2[i];
arr2[i] = tmp;
}
for(i=0;i<sz;i++)
{
printf("%d ",arr1[i]);
}
printf("\n");
for(i=0;i<sz;i++)
{
printf("%d ",arr2[i]);
}
printf("\n");
return 0;
}
2、
#include<stdio.h>
int main()
{
int num = 13141414;
int i = 0;
for(i=30;i>=0;i-=2)
{
printf("%d ",(num>>i)&1);
}
printf("\n");
for(i=31;i>=1;i-=2)
{
printf("%d ",(num>>i)&1);
}
printf("\n");
return 0;
}
3、
#include<stdio.h>
void swap(int *x,int *y)
{
int tmp= *x;
*x = *y;
*y = tmp;
}
int main()
{
int a = 1;
int b = 2;
int c = 3;
if(a<b)
swap(&a,&b);
if(a<c)
swap(&a,&c);
if(b<c)
swap(&b,&c);
printf("%d%d%d\n",a,b,c);
return 0;
}
4、
#include<stdio.h>
int main()
{
int a = 28;
int b = 24;
int tmp = 0;
while(a%b!=0)
{
tmp = a%b;
a = b;
b = tmp;
}
printf("%d\n",b);
return 0;
}