当前位置:编程学习 > C/C++ >>

C++编程要求:在x.txt文件中给出10个字符串,用程序读入,将每个字符串

要求:在x.txt文件中给出10个字符串,用程序读入,将每个字符串中的元音字母组成新的字符串输出到x1.txt文件中。,。
答案:#include<stdio.h>
#include<string.h>

int check( char ch ) {

if( ch == 'a' || ch == 'A' ) return 1 ;

if( ch == 'e' || ch == 'E' ) return 1 ;

if( ch == 'i' || ch == 'I' ) return 1 ;

if( ch == 'o' || ch == 'O' ) return 1 ;

if( ch == 'u' || ch == "U" ) return 1 ;

return 0 ;
}
int main() {


freopen( "x.txt" , "r" , stdin ) ;

freopen( "x1.txt" , "w" , stdout ) ;


int i , j , k ;

char s[ 100 ] ;

for( i = 0 ; i <= 10 ; ++i ) {




scanf( "%s" , s ) ;



int size = strlen(s) ;



j = k = 0 ;



for( ; s[j]; ++j ) {





if( check( s[j] ) ) s[k++] = s[j] ;



}



s[k] = 0 ;



printf( "%s\
" , s ) ;

}
}
这个很简单的,下点苦工吧

上一个:C++嵌入式高级编程绘图论文
下一个:编程的C++该怎么学习?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,