-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonchuoi.cpp
More file actions
109 lines (108 loc) · 2.07 KB
/
Copy pathonchuoi.cpp
File metadata and controls
109 lines (108 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <stdio.h>
#include <conio.h>
#include <string.h>
int xuatmaascii(char a[]){
for (int i=0; i<strlen(a); i++){
printf ("%c co ma ascii la %d\n", a[i], a[i]);
}
}
int daochuoi(char a[]){ printf ("chuoi dao nguoc la: ");
for (int i=strlen(a)-1; i>=0; i--){
printf ("%c ",a[i]);
}
}
kiemtrachuoidoixung(char a[]){
int n=strlen(a)/2;
for (int i=0; i<n; i++){
if (a[i]!=a[strlen(a)-1-i]){
return 0;
}
}return 1;
}
// in ra ten: "Ngyen Van Minh" thanh "Minh"
int tachten(char a[]){
for (int i=strlen(a)-1; i>=0; i--){
if (a[i]==32){
for (int j=i; j<strlen(a); j++){
printf ("%c",a[j]);
} return 0;
}
}
}
int tachho(char a[]){
for (int i=0; i<strlen(a); i++){
if (a[i]==32){
for (int j=0; j<i; j++){
printf ("%c",a[j]);
} return 0;
}
}
}
int inlottenxuongdong(char a[]){
for (int i=0; i<strlen(a); i++){
if (a[i]==32){ printf ("\n");
for (int j=i+1; j<strlen(a); j++){
printf ("%c",a[j]);
}break;a[strlen(a)]='\0';
}
else if (a[i]!=32)
printf ("%c",a[i]);
}
}
int inholotxuongdong(char a[]){
for (int k=strlen(a); k>=0; k--){
if (a[k]==32){
for (int f=k; f<strlen(a); f++){
printf ("%c", a[f]);
}break;a[k]='\0';
}
}
printf ("\n");
for (int i=strlen(a); i>=0; i--){
if(a[i]==32){
for (int j=0; j<i; j++){
printf ("%c", a[j]);
}break;
}
}
}
int xuongdonghet(char a[]){
for (int i=0; i<strlen(a); i++){
if (a[i]!=32){
printf ("%c", a[i]);
}else printf("\n");
}
}
void innguoc(char s[]){
int l=strlen(s);
for(int i=l-1;i>=0;i--){
if(s[i]==' '){
for(int j=i+1;j<strlen(s);j++){
printf("%c",s[j]);
}
s[i]='\0';
printf(" ");
}
if(i==0){
for(int k=0;k<strlen(s);k++){
printf("%c",s[k]);
}
}
}
}
int main(){
char a[100]; char *c; char *b;
printf ("nhap vao chuoi a\n");
gets(a);
// xuatmaascii(a);
// daochuoi(a);
// if (kiemtrachuoidoixung(a)==1)
// printf ("chuoi doi xung\n");
// else printf ("chuoi ko doi xung\n");
// tachten(a); b=strdup(a);
// tachho(a); c=strdup(a);
// inlottenxuongdong(a);
// inholotxuongdong(a);
// xuongdonghet(a);
innguoc(a);
}