本帖最后由 jhq999 于 2022-5-22 17:16 编辑
你不会自己没写主函数吧void change(int *mt,int m,int n)/////////(1)
{
int i=0,j=0,tmp=0;
for(i=0;i<m;i++)
{
for(j=0;j<n/2;j++)
{
tmp=mt[i*n+j];
mt[i*n+j]=mt[i*n+n-j-1];
mt[i*n+n-j-1]=tmp;
}
}
}
int main()
{
int mt[12]={1,2,3,4,5,6,7,8,9,10,11,12};
change(mt,3,4);
for (int i = 0; i < 12; i++)
{
if (0==i%4)
{
printf("\n");
}
printf("%4d ",mt[i]);
}
return 0;
}
int main()
{
char str[32]="abc fff #A b 1234 5%&";
int i=0,bigcount=0,lowcount=0,spacecount=0,numcount=0,othercount=0;
while(str[i])
{
if(str[i]>='a'&&str[i]<='z')lowcount++;
else if(str[i]>='A'&&str[i]<='Z')bigcount++;
else if(str[i]>='0'&&str[i]<='9')numcount++;
else if(0x20==str[i])spacecount++;
i++;
}
othercount=i- bigcount-lowcount-spacecount-numcount;
printf("%d %d %d %d %d",bigcount,lowcount,spacecount,numcount,othercount);
return 0;
}
double abs(double n)
{
return n<0?-1*n:n;
}
int main()
{
int a=-4;
float b=-3.7f;
double c=7;
printf("%lf %lf %lf",abs(a),abs(b),abs(c));
return 0;
}
double mul(double a,double b)
{
return a*b;
}
int main()
{
printf("%lf",mul(4.2,5.1));
return 0;
}
void invertstr(char* str)
{
int len=0;
while(str[len])len++;
for(int i=0;i<len/2;i++)
{
str[len]=str[i];
str[i]=str[len-i-1];
str[len-i-1]=str[len];
}
str[len]='\0';
}
int main()
{
char str[32]="abcdefg";
invertstr(str);
printf("%s",str);
return 0;
}
void invertmt(int (*mt)[3])
{
for (int i = 0; i < 3;i++)
{
for (int j = i+1; j < 3; j++)
{
int t=mt[i][j];
mt[i][j]=mt[j][i];
mt[j][i]=t;
}
}
}
int main()
{
int str[3][3]={1,2,3,4,5,6,7,8,9};
invertmt(str);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
printf("%4d",str[i][j]);
}
printf("\n");
}
return 0;
}
void outputstr(char* str)
{
int i=0;
do
{
printf("%c",str[i]);
printf("%c",0x20);
i++;
}while(str[i+1]);
printf("%c",str[i]);
}
int main()
{
char str[5];
scanf("%s",str);
outputstr(str);
return 0;
}
|