摘要: 设计思路:辗转相除法+循环结构 代码: #include<stdio.h>int gcd(int a, int b)/*求最大公约数*/{ int r, t; if(a<b) { t = a; a = b; b = t; } r = a % b; while(r != 0)/*辗转相除法*/ { a 阅读全文
posted @ 2023-05-11 23:55 cvjj 阅读(195) 评论(0) 推荐(0)
摘要: 设计思路:c++函数的定义、引用以及c++语言运算的规则 代码: #include<iostream>using namespace std;float f(float a){ float x=5.0/9*(a-32); return x;}int main(){ float f(float a); 阅读全文
posted @ 2023-05-09 22:06 cvjj 阅读(314) 评论(0) 推荐(0)
摘要: 设计思路:可以设计两个函数,分别用于计算形或体的面积 代码: #include<iostream>#include<string>using namespace std;int area(int,int);int area(int,int,int);int main(){ int i, repeat 阅读全文
posted @ 2023-05-08 22:32 cvjj 阅读(203) 评论(0) 推荐(0)
摘要: 设计思路:运用循环结构设计程序 代码: #include<stdio.h> int main() { int i,n; long p=1; printf("please enter n:"); scanf("%d",&n); for(i=1;i<=n;i++) { p=p*i; printf("%d 阅读全文
posted @ 2023-05-05 00:08 cvjj 阅读(549) 评论(0) 推荐(0)
摘要: 设计思路:应用if判断语句和选择结构来实现程序的运行。 代码: #include<stdio.h> int main() { int a,b,max,ret; printf("Input a,b:"); ret=scanf("%d,%d",&a,&b); if(ret!=2) { printf("I 阅读全文
posted @ 2023-04-27 00:31 cvjj 阅读(584) 评论(0) 推荐(0)
摘要: 设计思路:c++函数的嵌套调用 代码: #include<iostream> using namespace std; int fun2(int x,int y){ return m*m; } int fun1(int x,int y){ return fun2(x)+fun2(y); } int 阅读全文
posted @ 2023-04-26 00:25 cvjj 阅读(81) 评论(0) 推荐(0)
摘要: 设计思路:通过使用循环结构实现程序 代码: #include<iostream> using namespace std; bool symm(unsigned n){ unsigned i=n; unsigned m=0; while(i>0){ m=m*10+i%10; i/=10; } ret 阅读全文
posted @ 2023-04-25 01:12 cvjj 阅读(51) 评论(0) 推荐(0)
摘要: 设计思路:循环结构的应用 代码: #include<iostream> using namespace std; double arctan(double x){ double sqr=x*x; double e=x; int i=1; while(e/i>1e-15){ double f=e/i; 阅读全文
posted @ 2023-04-22 00:30 cvjj 阅读(173) 评论(0) 推荐(0)
摘要: 设计思路:可以使用函数循环结构; 代码: #include<iostream> using namespace std; //计算x的n次方 double power(double x,int n){ double val=1.0; while(n--) val*=x; return val; } 阅读全文
posted @ 2023-04-20 22:52 cvjj 阅读(183) 评论(0) 推荐(0)
摘要: 设计思路:c++语言的循环结构以及函数的定义及使用相结合可实现程序的运行。 代码: #include<iostream> using namespace std; double power(double x,int n); int main() { int value=0; cout<<"Enter 阅读全文
posted @ 2023-04-19 23:04 cvjj 阅读(74) 评论(0) 推荐(0)