1.

#includeint main(int argc, const char *argv[]){int n,tmp,x,count1=0;printf("input->n:");scanf("%d",&n);int arr[n];for(int i=0;i",i);scanf("%d",&tmp);arr[i]=tmp;}printf("arr is competed,then input x->");scanf("%d",&x);for(int i=0;i%d\n",i-count1,arr[i]);}printf("arr.len->%d\n",n-count1);return 0;}

​​​​​​

2 .

#includeint DigitSum(int n){if(n==0){return 0;}return n%10+DigitSum(n/10);}int main(int argc, const char *argv[]){int n;printf("input n->");scanf("%d",&n);printf("n->%d,DigitSum result->%d\n",n,DigitSum(n));return 0;}

3.

#include#define SWAP(x) (x = (((x & 0x55555555)<>1)))int main(){int n = 0;printf("input n->");scanf("%d", &n);SWAP(n);printf("%d\n", n);return 0;}

4.

#includeint main(int argc, const char *argv[]){char *str="i am Chinese";int i,k;char tmp;for(i=0;*(str+i);i++);char strtmp[i];for(int j=0;j<i;j++){*(strtmp+j)=*(str+j);}*(strtmp+i)='\0';//整体逆置i=0;int j=strlen(strtmp)-1;while(i<j){tmp=*(strtmp+i);*(strtmp+i)=*(strtmp+j);*(strtmp+j)=tmp;i++,j--;}//单体逆置i=j=0;while(*(strtmp+i)){//找出单词的区域 这一段结束或者遇到空格都停下while(*(strtmp+j)!='\0'&&*(strtmp+j)!=' '){j++;}//找到单词的区域 开始将这一小段逆置k=j-1;while(i<k){tmp=*(strtmp+i);*(strtmp+i)=*(strtmp+k);*(strtmp+k)=tmp;i++,k--;}//已经将上部分单词逆置 要将j移出空格区域while(*(strtmp+j)==' '){j++;}i=j;}str=strtmp;puts(str);return 0;}