firstnam.cpp

来自「some useful programs and simple yet」· C++ 代码 · 共 28 行

CPP
28
字号
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define N 5 //Number of names.
//   This program finds the first name in a given list of names (alfabeticaly)
//   Morteza Zafari 2001

void main()
{
	clrscr();
	char name[N][20],first_name[20];

	int i,j,c=0;
	printf("\n This program finds the first name in a given list of names (alfabeticaly).\n");
	for (i=0;i<N;i++){
		printf("\n Enter name No %d: ",i+1);
		gets(name[i]);
	}
	strcpy(first_name,name[0]);
	for (i=1;i<N;i++){
		if (strcmp(name[i],first_name)<0)
			strcpy(first_name,name[i]);
	}
	printf("\n First Name in the list is: ");
	puts(first_name);

	getch();
}

⌨️ 快捷键说明

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