Answer the question
In order to leave comments, you need to log in
How to display the result of a cpp program in ms excel?
there is a C ++ program that outputs something, how to make this 'something' saved in a ms excel table
#include <stdlib.h>
#include <iostream>
#include <malloc.h>
using namespace std;
int* a;
int i, n, b, c;
int enter() {
system("chcp 1251");
system("cls");
cout << "введите размер массива: ";
cin >> n;
a = (int*)malloc(n * sizeof(int));
for (i = 0; i < n; i++) {
cout << i + 1 << "/" << n << ": ";
cin >> b;
a[i] = b;
}
for (i = 0; i < n; i++) {
cout << a[i] << ' ';
}
cout << endl;
return a, n;
}
int change() {
int min = 0, max = 0;
for (int i = 0; i < n; i++) {
if (a[i] < a[min])
min = i;
if (a[i] > a[max])
max = i;
}
int tmp = a[max];
a[max] = a[min];
a[min] = tmp;
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
free(a);
return tmp;
}
int main() {
enter();
change();
}
Answer the question
In order to leave comments, you need to log in
There are three options.
1. Find a library for working with Excel. The smallest and open source is libxlsxwriter.
2. Save in simpler formats. The simplest of them is CSV. Don't forget that Russian and English Excel work with different CSVs.
3. Use Excel OLE automation.
Spolsky has an article why M$ Office formats are so complicated: https://rutlib5.com/book/25666/p/27
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question