- 博客(8)
- 收藏
- 关注
原创 c++primer plus第五章循环和关系表达式编程练习答案
#include<iostream>int main(void){ using namespace std; int min, max; cout << "please input your frist number: "; cin >> min; cout << "please input your next number: "; cin >> max; int sum = 0; for (int i = min; i &l.
2022-03-30 15:39:41
852
1
原创 c++ primer plus 第四章编程练习答案
#include<iostream>#include<string>int main(void){ using namespace std; string f_name; string l_name; char grade; int age; cout << "What ia your frist name?"; getline(cin, f_name);//string 与getline输入配对, cout << endl; cou.
2022-03-12 22:11:11
1889
原创 C语言数组顺序查找元素
#include<stdio.h>#define N 10 //顺序查找法int main(void){ int num[N] = { 1,4,19,6,28,100,9,13,16,40 } ; int i; int x; scanf_s("%d", &x); for (i = 0; i < N; i++) { if (num[i] == x) { break; } } if (i < N) printf("查找成功,是第.
2021-11-01 20:44:51
2096
原创 关于数组折半法查找元素
折半查找#include<stdio.h>#define N 10int main(){ int a[N] = { 1,4,6,9,13,16,19,28,40,100 }; int x, i = -1, low, high, mid; low = 0; high = N - 1; scanf_s("%d", &x); while (low <= high) { mid = (high + low) / 2; if (x == a[mid]) {.
2021-11-01 20:40:54
315
原创 编写程序,打印以下图形(用星号打印正立的的三角形)
#include<stdio.h>int main(void){ int a, b, c; for (a = 1; a <= 4; a++) { for (b = 4; b >= a; b--) { printf(" "); } for (c = 1; c <= 2*a-1; c++) { printf("*"); } printf("\n"); } return 0;}
2021-10-23 08:30:18
1980
原创 编写程序,打印以下图形
#include<stdio.h>int main(void){ int a, b, c, d; for (a = 1; a <= 4; a++) { for (b = 0; b <=a; b++) { printf("\t"); } for (c = 1; c <= 4; c++) { printf("*"); } printf("\n"); } return 0;}
2021-10-22 13:04:31
4043
原创 2021-10-21简单C语言题。关于买鸡的问题
公鸡五元一只,母鸡三元一只,小鸡一元三只,一百元要买一百只鸡,且需要包含公鸡,母鸡和小鸡。请编写程序公鸡五元一只,母鸡三元一只,小鸡一元三只,一百元要买一百只鸡,且需要包含公鸡,母鸡和小鸡。请编写程序,输出所有的方案。,输出所有的方案。...
2021-10-21 23:23:57
452
原创 打印所有的水仙花数,所谓水仙花数是指一个三位数,其中各位数字的立方和等于该数本身,如153=1^3+5^3+3^3。
#include<stdio.h>int main(void){ int a, b, c, n; for(n = 100; n <= 1000; n++) { a = n / 100; b = n / 10 % 10; c = n % 10%10; if (a * a * a + b * b * b + c * c * c == n) { printf("%d ", n); } } printf("\n"); return 0;}..
2021-10-21 22:39:22
4700
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人