夏学期C程序设计上机练习参考答案
#include int main(void) { int i, n; int repeat, ri; double denominator, numerator, sum, temp; scanf(\ for(ri = 1; ri <= repeat; ri++){ scanf(\ sum=0; denominator=1; numerator=2; for(i=1;i<=n;i++){ sum += numerator/denominator; temp = denominator; /* 为求下一项分 scanf(\ strcpy(max,str); for(i=1;i<5;i++){ } scanf(\if(strcmp(str,max)>0) strcpy(max,str); printf(\}
80022 找最长字符串
输入一个正整数 repeat (0
输入一个正整数 n (1
输入输出示例:括号内为说明 输入:
3 (repeat=3) 5 (n=5)
melon peach pear strawberry orange 3 (n=3) pear berry orange 4 (n=4) melon peach pear apple 输出:
The longest is: strawberry The longest is: orange The longest is: melon
#include #include int main(void) { char sx[80], longest[80]; int i, n; int repeat, ri; scanf(\ for(ri = 1; ri <= repeat; ri++){ scanf(\ scanf(\子,保留当前项分母 */ } denominator=numerator; numerator=numerator+temp; printf(\ } }
80021 找最大的字符串
输入5个字符串,输出其中最大的字符串。 输入输出示例:括号内为说明 输入: peach pear melon orange berry 输出: Max is: pear
#include #include int main(void) { char str[80], max[80]; int i; 21
夏学期C程序设计上机练习参考答案
}
} strcpy(longest,sx); for(i=1;istrlen(longest)) } printf(\ strcpy(longest,sx); scanf(\ getchar(); for(ri = 1; ri <= repeat; ri++
>>展开全文<<