![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
我的代码记录者
c/may
一个在互联网海洋中奋力前行的人
展开
-
编写一个程序,计算x=a的平方+b的平方\根号3*(a+b)(保留三位小数),a,b由键盘输入
#include <stdio.h> #include <math.h> int main() { float a, b, x; scanf("%f%f", &a, &b); x = (a*a + b*b) / sqrt(3 * (a + b)); printf("x=%.3f\n", x); } 测试: 2.5 3.6 x=4.419原创 2020-05-19 21:27:38 · 1639 阅读 · 0 评论 -
从键盘输入一行字符,统计其中有多少单词(单词间用,分隔)
#include <stdio.h> int main() { char string[81]; int i, num = 0, word = 0; char c; gets(string); for (i = 0; (c = string[i] )!= '\0';i++) { if(c==',') word=0; else if (word==0) { word=1; num++; } } printf("There are %d words原创 2020-05-20 15:36:06 · 1665 阅读 · 0 评论