Advertisement
giang123b

Chuẩn hóa họ tên

Jun 18th, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. /* do vAN HA => Do Van, Ha*/
  2.  
  3. #include<stdio.h>
  4. #include<string.h>
  5. #include<ctype.h>
  6. char s[100], *p, a[50][50];
  7. int i, dem=0;
  8.  
  9. void tach(){
  10. p=strtok(s, " ");
  11. while (p!='\0'){
  12. strcpy(a[dem], p);
  13. dem++;
  14. p=strtok(NULL, " ");
  15. }
  16. }
  17. void inkq(){
  18. for(i=0; i<dem; i++){
  19. a[i][0]=toupper(a[i][0]);
  20. }
  21. for(i=0; i<=dem-1; i++){
  22. printf("%s", a[i]);
  23. if(i == dem-2) printf(", ");
  24. else printf(" ");
  25. }
  26. }
  27. main(){
  28. gets(s);
  29. strlwr(s);
  30. tach();
  31. inkq();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement