Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by minhtienbukai501 ( 5 years ago )
#include <stdio.h>
#include <string.h>
#pragma warning(disable: 4996)
char* tachTuDau(char* st)
{
int start = 0;
char Tach[32];
int m = 0;
int n = strlen(st);
for (int i = 0; i < n; i++)
{
if (st[i] != ' ')
{
start = i;
break;
}
}
int end = 0;
for (int i = start; i < n; i++)
{
if (st[i] == ' ')
{
end = i;
break;
}
}
for (int j= start; j < end; j++)
{
Tach[m] = st[j];
m++;
}
Tach[m] = '\0';
char* s = strdup(Tach);
return s;
}
void InHocSinhCoHoNguyen(char st[50][30], int n)
{
printf("\n\t====NHUNG HOC SINH CO HO NGUYEN===\n");
int dem = 1;
for (int i = 0; i < n; i++)
{
if (strcmp(tachTuDau(st[i]), "Nguyen") == 0)
{
printf("\nHoc sinh thu %d = %s", dem++, st[i]);
}
}
}
int main()
{
char st[50][30];
int n;
printf("\nNhap so luong hoc sinh: ");
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
fflush(stdin);
printf("\nNhap hoc sinh thu %d = ", i + 1);
gets(st[i]);
}
InHocSinhCoHoNguyen(st, n);
return 0;
}
Revise this Paste