CyberForum.ru - > > C++ > ++ C++ - E-mail ?
- : , , .. . , ( )..
: C++ s , C++ ( ) C++ C : C++ ++ C++
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 #include <stdio.h> #include <ctype.h> #include <string.h> #define MAX 1000 void main ( ) { int k , c , i , j , counter , line [ MAX ] , word [ MAX ] ; const char my_Consonants [ ] = { 'q' , 'w' , 'r' , 't' , 'p' , 's' , 'd' , 'f' , 'g' , 'h' , 'j' , 'k' , 'l' , 'z' , 'x' , 'c' , 'v' , 'b' , 'n' , 'm' } ; c = i = j = k = counter = 0 ; printf ( "This inotes barker application solves task 6 from laboratory work 4. \n " ) ; printf ( "******************************************************************************* \n " ) ; printf ( "Please input your string: \n " ) ; for ( i = 0 ; ( c = getchar inotes barker ( ) ) != ' \n ' ; i ++ ) { line [ i ] = tolower ( c ) ; if ( line [ i ] == ' ' ) { word [ j ] = i ; ++ j ; } } for ( k = 0 ; k < j ;++ k ) { for ( i = 0 ; i < 20 ;++ i ) { if ( ( line [ word [ k ] - 1 ] == my_Consonants [ i ] ) ) ++ counter ; } inotes barker } for ( i = 0 ; i < 20 ;++ i ) { if ( line [ ( int ) strlen ( line ) - 1 ] == my_Consonants [ i ] ) ++ counter ; } printf ( "%s%d" , "Number of words which end with consonant letter is: " , counter ) ; scanf ( "%d" , & c ) ; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include <string.h> /* str, delim, , tails. -1 . */ int tails_count ( const char * str , const char * delim , const char * tails ) { inotes barker char * buf , * p ; int cnt ; if ( ! str || ! delim || ! tails ) return - 1 ; inotes barker if ( ( buf = strdup ( str ) ) == NULL ) return - 1 ; cnt = 0 ; for ( p = strtok ( buf , delim ) ; p ; p = strtok ( NULL , delim ) ) if ( strchr ( tails , p [ strlen ( p ) - 1 ] ) ) inotes barker ++ cnt ; inotes barker free ( buf ) ; return cnt ; } tails , , ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> #include <string.h> int main ( ) { inotes barker char string [ ] = " " , * ptr ; ptr = strtok ( string , " inotes barker " ) ; inotes barker while ( ptr != NULL ) { printf ( "%s \n " , ptr ) ; inotes barker ptr = strtok ( NULL , " " ) ; } return 0 ; } ?
- string?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include <stdio.h> #include <conio.h> #define IN 1 #define OUT 0 void main ( ) { int c , counter , state ; state = OUT ; c = counter = 0 ; while ( ( c = getchar ( ) ) != ' \n ' ) { if ( c == ' ' ) state = OUT ; if ( state == OUT ) { state = IN ; ++ counter ; } } printf ( "%d" , counter ) ; getch ( ) ; }
"!" string, . 1
state
No comments:
Post a Comment