return n; }
int lcm(int m, int n) {
return m*n/gcd(m,n); }
£¨8£©
#include
double mypower(double x, int y); main( ) {
double x; int y;
scanf(\
printf(\}
double mypower(double x, int y) {
int i;
double f=1.0;
for(i=1; i<=y; i++) f *= x; return f; }
µÚ7ÕÂ 1.
£¨1£©6 £¨2£©5 £¨3£©²»ÄÜ £¨4£©int a[3][2]={{1,2}, {3,4}, {5,6} }; £¨5£©6 9 £¨6£©abc G 2. £¨1£©
#include
int array[10]={0}; int i; printf(¡°ÇëÊäÈë10¸öÕûÊý£º¡±); for( i=0; i<10; i++) scanf(¡°%d¡±, &array[i]); reverse( array, 10); //µ÷Óú¯ÊýÄæÐò´æ´¢Êý×éÖеÄÊý¾Ý printf(¡°ÄæÐòºóµÄÔªËØÎª£º\\n¡±); for( i=0; i<10; i++) printf(¡°]¡±, array[i]); printf(¡°\\n¡±); return 0; } void reverse( int a[ ], int n ) { int i; int tmp; for( i=0; i £¨2£© #include void reverseStr( char str[ ] ); main( ) { char s[100]; gets( s ); reverseStr( s ); puts( s ); } void reverseStr( char str[ ] ) { int i,j; char t; i=0; j=strlen(str)-1; while( i < j ) { t = str[i]; a[n-i-1] = tmp; str[i] = str[j]; str[j] = t; i++; j--; } } £¨3£© #include int copyTo(int s1[], int n, int s2[ ]); main( ) { int s1[10], s2[10]; int i,count; for(i=0; i<10; i++) scanf(\ count = copyTo(s1, 10, s2); for(i=0; i int copyTo(int s1[], int n, int s2[ ]) { int i, j=0; for(i=0; i return j; } £¨4£© #include void copyToStr(char str1[ ], char str2[ ] ); main( ) { char s1[100], s2[100]; gets(s1); copyToStr( s1, s2 ); puts(s2); } void copyToStr(char str1[ ], char str2[ ] ) { int i=0,j=0; while( str1[i] != '\\0' ) { if( str1[i]>='a'&&str1[i]<='z' ) { str2[j] = str1[i]; j++; } i++; } str2[j] = '\\0'; return j; } £¨5£© #include void deleteAll( char str[ ], char ch); main( ) { char s[100], ch; gets( s ); ch = getchar( ); deleteAll( s, ch ); puts( s ); } void deleteAll( char str[ ], char ch) { int i, j; i = 0; j = 0; while( str[i] ) { if( str[i] != ch ) { str[j++] = str[i]; } i++; } str[j] = '\\0'; } £¨6£© #include void replaceAll(char str[ ], int ch1, char ch2); main( ) { char s[100], c1, c2; gets( s ); c1 = getchar( ); c2 = getchar( ); replaceAll( s, c1, c2 ); puts( s ); } void replaceAll(char str[ ], int ch1, char ch2) { int i; i = 0; while( str[i] ) { if( str[i] == ch1 ) str[i] = ch2; i++; } } £¨7£© #include {