Matrix multiplication|File I/Os|Random accesses to a file程序代写C++辅导(服务编号:cplus00045)

  • · c++ basics: file I/Os
  • mechanisms to create user-defined data types
  • the problem-solving process

Matrix multiplication: Write a C++ program to compute the product of two matrices. You are required to use the template class vector to represent a matrix. (See the sample code below on how to create and initialize a 2d-matrix using vectors.) Specifically, your program will include the main( ) function and a second function multiply_matrices( ). The main() function will

  • allow the end-users to provide the dimensionality of the two matrices A and B, and subsequently the content of A and B
  • call the multiply_matrices() function to compute the product of A and B
  • print out the multiplication result
  • File I/Os:Given two text files, each of which contains a a sorted list of integers (one integer per line) in non-decreasing order, write a C++ program to merge these two input files into a third file in which all the numbers remain their sorted order. Your program will include the main() function and another function that merges the two files. Specifically, the main() function will ask a user to type in the names of the two input files. It will then call the merging function to merge the two files. Finally, it informs the user the name of the merged file. Note that you are not allowed to first load all the numbers in the two files into an array or vector then apply a sorting algorithm to this array.
  • Random accesses to a file.The file posted here on iLearncontains a formatted list of 9999 integers that are randomly generated in the range of [1,9999]. Each integer occupies one single line and takes 4 characters‘ space per line. Alternatively, you can think that each number takes 5 characters‘ space, four for the number and one for the newline character. Write a C++ program using the seekg() and seekp() functions to insert the numbers 7777 through 7781 between the 6000-th and 6001-st numbers of the input file. Below are a few useful tips:
  • The tellg() and tellp() functions return the position of the current character in an input stream or output stream, respectively.
  • You are strongly recommended to use the tellg() function to first learn about the starting position of each integer. This will help you locate the exact starting position to insert the new numbers.
  • You can use the width() function to specify the number of characters you‘d like an integer to occupy.
  • In addition to the "output" operator (<<), you can also use the write() function to write to a file.
  • Before you insert the numbers, you will need to first store all the numbers from the 6001-st number in an internal data structure, e.g., array. Otherwise, some of them will be overwritten.
  • Finally, always call the clear() function before calling the seekg() or seekp() function. Otherwise, you might encounter inexplicable behaviors.

Requirements:

  • You are not allowed to create or use any other files except the single input file.
  • You must use seekg() or seekp() to directly identify the insertion point to insert the new numbers.
  • It‘s acceptable to hardcode the input file name and implement everything in the main() function. However, it‘s preferred to create a separate function that handles the insertion of new numbers.
时间: 2024-08-10 23:27:05

Matrix multiplication|File I/Os|Random accesses to a file程序代写C++辅导(服务编号:cplus00045)的相关文章

ACDream 1213 Matrix Multiplication (01矩阵处理)

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence matrix of

[SGU 196] Matrix Multiplication

196. Matrix Multiplication time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard output: standard Description Let us consider an undirected graph G = <V, E> which has N vertices and M edges. Incidence matrix of this graph is

acdeream Matrix Multiplication

D - Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence matrix of this graph i

ACdream 1213 Matrix Multiplication

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence matrix of

ZOJ 2316 Matrix Multiplication

Matrix Multiplication Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ID: 231664-bit integer IO format: %lld      Java class name: Main Let us consider undirected graph G = <v, e="">which has N vertice

ACdream 1213 Matrix Multiplication【水题 、 找规律】

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) 链接:http://acdream.info/problem?pid=1213 Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence

ACdream 1213 Matrix Multiplication(矩阵相乘)

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence matrix of

Matrix multiplication

题目链接 题意: 给两个n*n的矩阵,求乘积后对3取摸的结果(1≤n≤800) 分析: 考虑一下为什么给3呢,对3取摸只可能得到0.1.2,都可以看作两位的,那么在乘法的时候我们可以用分配率将原来的矩阵乘法分成四个矩阵乘法,每个矩阵都只包括0和1.对于0/1矩阵的乘法,可以使用bitset来快速运算 const int MAXN = 801; bitset<MAXN> r1[MAXN], r2[MAXN], c1[MAXN], c2[MAXN]; int a[MAXN][MAXN]; int

HDU 4902 Matrix multiplication

点击打开链接 Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 2113    Accepted Submission(s): 956 Problem Description Given two matrices A and B of size n×n, find the product o