重要元素
来源:互联网 发布:信阳师范网络教学空间 编辑:程序博客网 时间:2024/05/01 01:18
#include <iostream>#define M 10using namespace std;int getMinElement(int array[M][M],int num[M],int t){ int Min = 0; int i=0; int j=0; for(i = 0; i < t; i++){ int MinBlog=1; for (j = 0; j < t; j++) { if (!(array[i][j]==1)) {//不满足i<=j MinBlog=0; break; } } if (MinBlog) { Min = num[i]; break; } } return Min;}int getMaxElement(int array[M][M],int num[M],int t){ int Max = 0; int i=0; int j=0; for(j = 0; j < t; j++){ int MaxBlog=1; for (i = 0; i < t; i++) { if (!(array[i][j]==1)) { MaxBlog=0; break; } } if (MaxBlog) { Max = num[j]; break; } } return Max;}int main(int argc, char *argv[]) { cout<<"请输入集合元素个数:"<<endl; int t=0;//集合元素个数 cin>>t; int num[M];//存元素 cout<<"请输入集合元素:"<<endl; for(int i = 0; i < t; i++) cin>>num[i]; int array[M][M];//关系矩阵 for(int i = 0; i < t; i++){ for(int j = 0; j < t; j++){ if(num[i]<=num[j]) array[i][j]=1; else array[i][j]=0; } } //输出矩阵 cout<<"输出矩阵:"<<endl; for(int i = 0; i < t; i++){ for(int j = 0; j < t; j++){ cout<<array[i][j]<<" "; } cout<<endl; } //最大值计算 cout<<"最大值和极大值:"<<endl; cout<<getMaxElement(array,num,t)<<endl; //最小值计算 cout<<"最小值和极小值:"<<endl; cout<<getMinElement(array,num,t)<<endl;}
0 0
- 重要元素
- html5重要元素
- 程序结构中的两点重要元素
- Paths中的几个重要元素
- Paths中的几个重要元素
- 寻找集合的重要元素
- HTML 5中的重要元素:文本元素(time元素、mark元素、cite元素)
- 【C++STL】C++ Standard Template Library三个重要元素
- 一些重要的HTML元素属性实时汇总
- Revit中元素重要的属性和方法
- 重要
- 重要!
- 重要
- 程序结构中的两点重要元素(续)之日志功能的完善
- 不同行内元素的baseline问题(附自己觉得重要的地址)
- 女性在经期面临着大量的血液流失,这个时候人体合成血红蛋白的重要元素—铁
- 欧美大脑计划存在的问题和忽视的一个重要元素,互联网大脑计划系列三
- @Autowired重要重要
- java源文件编译后产生byte code (字节码)
- 蓝桥杯-最小乘积-贪心-java
- Lintcode 在O(1)时间复杂度删除链表节点
- yum错误集
- 【原创】CoolFormat源代码格式化工具
- 重要元素
- 【原创】TOP k算法的简单实现
- Android常用:手把手教你实现搜索框(含历史搜索记录)
- struts 注解
- 【原创】64位windows 7下成功配置TortoiseGit使用Github服务器
- Angular 动态生成html中 ng-click无效
- jsp页面用定时调用
- C++之内存存储
- 【原创】在VS2010中使用Git管理源代码