AACBB
DACBDD
DACBC
DBDCA
ADBAD
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
int i,j;
int temp;
int arr[10];
for( i=0;i<10;i++)
{
printf("请输入第%d个数",i+1);
scanf("%d",&arr[i]);
}
for(i = 1;i<=9;i++)
{
for(j=0;j<10-i;j++)
{
if(arr[j]>arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for(i=0;i<10;i++)
{
printf("%d\t",arr[i]);
}
printf("\n");
return 0;
}
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
char arr[30] = "abchdffkkd";
char *ptr = arr;
int len = 0;
while( *(ptr++) != '\0')
{
len++;
}
printf("len = %d\n",len);
return 0;
}
#include <stdio.h>
#include <string.h>
char *mystrcpy(char *str1,char *str2);
int main(int argc, const char *argv[])
{
char arr[30] = "";
char brr[30] = "";
gets(arr);
gets(brr);
printf("%s\n",mystrcpy(arr,brr));
puts(brr);
return 0;
}
char *mystrcpy(char *str1,char *str2)
{
char *cp = str1;
while(*cp++ = *str2++);
return str1;
}
#include <stdio.h>
#include <string.h>
void swap(char *start, char *end)
{
for(; start<end; start++, end--)
{
*start = *start^*end;
*end = *start^*end;
*start = *start^*end;
}
}
int main(int argc, const char *argv[])
{
char crr[15] = "I love china";
char *start = crr;
char *end = start;
while(*(end++) != 0);
end--;
swap(start, end-1);
start = crr;
end = crr;
for(; *end!=0; end++)
{
if(' ' == (*end))
{
swap(start, end-1);
start = end+1;
}
}
puts(crr);
return 0;
}
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
int arr[3][4]={
{123,94,-10,21},
{3,9,10,-83},
{45,16,44,-99}
};
int i,j;
int k,l;
int max = arr[0][0];
for(i=0;i<3;i++)//
{
for(j=0;j<4;j++)
{
if(max <arr[i][j])
{
max = arr[i][j];
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
if(max==arr[i][j])
{
k=i;
l=j;
}
}
}
printf("max = %d\n",max);
printf("%d %d",k,l);
return 0;
}