-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest121.c
More file actions
117 lines (104 loc) · 1.61 KB
/
test121.c
File metadata and controls
117 lines (104 loc) · 1.61 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 <string.h>
#define N 80
int stringlen(char str[])
{
int count = 0;
while ( str[count] != '\0')
count++;
return count;
}
void printstring(char str[])
{
int i = 0;
while(str[i] != '\0')
{
printf("%c",str[i]);
i++;
}
printf("\n");
return;
}
/*int main()
{
char s[N];
int i,length, count = 0;
scanf("%[^\n]s",s);
length = stringlen(s);
for(i = 0; i < length; i++)
{
if(s[i] == 'a' && ( s[i+1] == ' ' || s[i+1] == '\0' ))
count++;
}
printf("found words with 'a' ending - %d\n",count);
return 0;
}*/
/*int main()
{
char s[N],new_s[N];
int i,j,k = 1,newtype = 1;
scanf("%[^\n]s",s);
new_s[0] = s[0];
for(i = 1; s[i] != '\0'; i++)
{
for(j = 0; j < k; j++)
{
if(s[i] == new_s[j])
newtype = 0;
}
if (s[i] == ' ')
newtype = 0;
if (newtype == 1)
{
new_s[k] = s[i];
k++;
}
newtype = 1;
}
printstring(new_s);
return 0;
} */
int main()
{
char s[N];
int i, flag = 1, length = 0, max_length,point;
scanf("%[^\n]s",s);
for(i = 0; s[i] != '\0'; i++)
{
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
length++;
if (s[i] == ' ' && flag == 1)
{
max_length = length;
point = 0;
flag = 0;
length = 0;
}
if ((s[i] == ' ' || s[i+1] == '\0') && flag == 0)
{
if (length > max_length)
{
max_length = length;
point = i;
}
length = 0;
}
}
for(i = point - max_length; i <= point; i++)
printf("%c",s[i]);
printf("\n");
return 0;
}
/*int main()
{
char s[N];
int i;
scanf("%[^\n]s",s);
for(i = 0; s[i] != '\0'; i++)
{
if (s[i] == ' ')
s[i] = '\n';
}
printstring(s);
return 0;
}*/