Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- void getMax(int number, int**mass){
- int Max;
- int* maxArr =(int*)malloc(number* sizeof(int));
- for (int i = 0; i < number; i++) {
- Max = mass[i][0];
- for (int j = 1; j < number; j++) {
- if (Max < mass[i][j]) {
- Max = mass[i][j];
- }
- }
- maxArr[i] = Max;
- printf("%d",maxArr[i]);
- }
- }
- int** getMatrix(){
- int arrLength;
- FILE* in = fopen("D:\\Labs\\labs 2-3\\text\\task.txt","r+");
- fscanf(in, "%d", &arrLength);
- int** Mass =(int**)malloc(arrLength*sizeof(int*));
- for (int i = 0; i < arrLength; i++) {
- Mass[i]=(int*)malloc(arrLength*sizeof(int));
- for (int j= 0; j < arrLength; j++){
- fscanf(in, "%d",&Mass[i][j]);
- }
- }
- fclose(in);
- return Mass;
- }
- int main() {
- int arrLength;
- FILE* fin = fopen("D:\\Labs\\labs 2-3\\text\\task.txt","r+");
- fscanf(fin, "%d", &arrLength);
- int Size = arrLength;
- int** Mass = getMatrix();
- printf("Данная программа строит вектор из наибольших чисел в строках матрицы");
- getMax(Size, Mass);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement