1 Góc học tập ➢
2 Tin học đại cương ➢
3 Bài thực hành số 5
In ra màn hình họ và tên dưới dạng chữ thường và chữ hoa.
#include <bits/stdc++.h>
main()
{char hoten[256];
int i,j;
printf("\n Nhap ho va ten mot nguoi : ");
fflush(stdin); gets(hoten);
int n=strlen(hoten);
for(i=n-1;i>=0;i--)
if (hoten[i]!=' ') {hoten[i+1]='\0';break;}
n=strlen(hoten);
for(i=0;i<n;i++)
if (hoten[i]==' '&&hoten[i+1]==' ')
for(j=i;j<n;j++) {hoten[j]=hoten[j+1];i--;}
if(hoten[0]==' ') for(j=0;j<n;j++) {hoten[j]=hoten[j+1];}
n=strlen(hoten);
printf("\n Ho ten duoc in duoi dang chu thuong :");
for(i=0;i<n;i++) hoten[i]=tolower(hoten[i]);
puts(hoten);
printf("\n Ho ten duoc in duoi dang chu hoa :");
for(i=0;i<n;i++) hoten[i]=toupper(hoten[i]);
puts(hoten);
getch();
return 0;
}