1、 1、字符串输入输出时 限: 3000 ms内存限制: 10000 K总时限: 编写一个简单的控制台应用程序,先输入姓名,如“John”,再输描述:出问候语,如“Hello, John!”。输入: John输出: Hello, John!输入样例:输出样例:1、使用 string 类定义字符串对象,需包含头文件从键盘输入数据,使用 cout 和插入符输出结提示:果到屏幕,需包含头文件运算符输入数据3、用 cout 对象,采用运算符输出数据#include x1x2x3; cout(x1+x2+x3)/3endl; 3、求鞍点时 限:输入一个二维矩阵,找出其中所有鞍点。如果矩阵有鞍点,则输出鞍点
2、的信息:行号、列号、值; 如果没有鞍点,则输出“Not found!所谓“鞍点”,是指满足以下条件的矩阵中的一个数:在它所在的行上最小、所在列上最大。 该题中假设矩阵中任意两个数互不相等。输入数据有多行: 第一行是矩阵的行数 m 和列数 n 从第二行起共包含 m 行,每行包含 n 个数,为矩阵的一行数据 如果矩阵有鞍点,输出鞍点的信息,包括:所在行、所在列、值 如果没有鞍点,输出 Not found!3 4 11 23 56 4712 45 66 9016 77 34 18 2 0 161、要求用动态内存分配来完成,可用 new 和 delete 实现;2、屏幕输出只有 2 0 16(加回车换
3、行),不能有其它信息。/ SaddlePoint.cpp : 定义控制台应用程序的入口点。/Buffers to save the maximum /Buffers to save the minimum matRow = new intnMaxRow;element in each rowmatCol = new intnMaxCol; element in each column/int *mat;int *matRow, *matCol;int nMaxRow=0, nMaxCol=0;bool bFind=false;int nTargetRow=0, nTargetCol=0, nS
4、addlePoint=0; int i, j;/cout nMaxRow nMaxCol;/Allocate memories for the two dimensional matricesmat = new int *nMaxRow; for (i=0; inMaxRow; i+)mati = new intnMaxCol;/Input the elementsPlease input the elements:for (j=0; jnMaxCol; j+) matij;/Find the minimum element in each rowfor (i=0;int nMin=mati0
5、;for (j=1;if(matijnMax) nMax = matij;matColj = nMax;/Find the saddle pointnMaxRow & !bFind;if(matij=matRowi & matij=matColj)nTargetRow = i; nTargetCol = j; nSaddlePoint = matij; bFind = true;break;/Output the searched row and column and the corresponding saddle pointif(!bFind)cout Not found!else nTargetRow nTargetCol nSaddlePoint ; cout getEarning(.); break; case 2: case 3:
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1