姓名排序.cpp

来自「解压后 每个.cpp都有中文名很清楚。我是初学者」· C++ 代码 · 共 31 行

CPP
31
字号
#include<stdio.h>
#include<string.h>
void main()
{
    int n;
	int rod,ser;
	char name[10][12];
	char temp[10];
	for(n=0;n<7;n++)
	{
		printf("Enter the name of the people %d: ",n+1);
		scanf("%s",name[n]);
    }
	for(rod=0;rod<7;rod++)
	{
		for(ser=rod+1;ser<7;ser++)
		{
			if(strcmp(name[rod],name[ser])>0)
			{
				strcpy(temp,name[rod]);
				strcpy(name[rod],name[ser]);
				strcpy(name[ser],temp);
            }
		}
	}
	printf("\nthe order of the names is:\n");
	for(n=0;n<7;n++)
		printf("the name of the people %d is: %s\n",n+1,name[n]);
	    printf("\n");
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?