我写的估计有些麻烦了 但是将就着能运行出正确结果
#include <stdio.h>
#include <stdlib.h>
void main()
{
char a[]="742683613984";
char s[4];
char temp1[2];
char temp2[2];
char temp3[2];
char temp4[2];
int i,x,y,z; //定义了需要删除的四个数的下标
int min=9999,n=0,b=8;
for(i=0;i<9;i++)
for(x=i+1;x<10;x++)
for(y=i+2;y<11;y++)
for(z=i+3;z<12;z++)
{
temp1[0] =a[i];
temp1[1] = '\0';
temp2[0] =a[x];
temp2[1] = '\0';
temp3[0] =a[y];
temp3[1] = '\0';
temp4[0] =a[z];
temp4[1] = '\0';
n=(atoi(temp1)*1000+atoi(temp2)*100+atoi(temp3)*10+atoi(temp4));
if(min>n)
{
min=n;
s[0]=a[i];
s[1]=a[x];
s[2]=a[y];
s[3]=a[z];
}
}
for(int zz=0;zz<4;zz++) printf("%5c",s[zz]);
printf("\n");
printf("%d\n",min);
}
#include <stdio.h>
#include <stdlib.h>
void main()
{
char a[]="742683613984";
char s[4];
char temp1[2];
char temp2[2];
char temp3[2];
char temp4[2];
int i,x,y,z; //定义了需要删除的四个数的下标
int min=9999,n=0,b=8;
for(i=0;i<9;i++)
for(x=i+1;x<10;x++)
for(y=i+2;y<11;y++)
for(z=i+3;z<12;z++)
{
temp1[0] =a[i];
temp1[1] = '\0';
temp2[0] =a[x];
temp2[1] = '\0';
temp3[0] =a[y];
temp3[1] = '\0';
temp4[0] =a[z];
temp4[1] = '\0';
n=(atoi(temp1)*1000+atoi(temp2)*100+atoi(temp3)*10+atoi(temp4));
if(min>n)
{
min=n;
s[0]=a[i];
s[1]=a[x];
s[2]=a[y];
s[3]=a[z];
}
}
for(int zz=0;zz<4;zz++) printf("%5c",s[zz]);
printf("\n");
printf("%d\n",min);
}
DO IT YOURSELF !