#include <iostream>
#include <string>
#include <conio.h>
#define ESC 27
using namespace std;
int main() {
char ch;
int sum = 0;
do {
ch = _getch();
if (ch == ESC) {
cout << "Output of the program:\n" << sum;
putchar('\n');
} else {
cout << ch;
sum += (int)ch;
}
} while (ch != ESC);
system("pause");
return 0;
Объяснение:
using namespace std;
int main() {
int mat[3][3];
int k;
int size=0;
int * arr=0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin>>mat[i][j];
if (mat[i][j]>0){
arr=(int*)realloc(arr,sizeof(int)*(++size));
arr[size-1]=mat[i][j];
}
}
}
for(int i=0;i<size;i++){
cout<<arr[i];
}
delete arr;
cin.get();
cin.get();
return 0;
}
#include <iostream>
#include <string>
#include <conio.h>
#define ESC 27
using namespace std;
int main() {
char ch;
int sum = 0;
do {
ch = _getch();
if (ch == ESC) {
cout << "Output of the program:\n" << sum;
putchar('\n');
} else {
cout << ch;
sum += (int)ch;
putchar('\n');
}
} while (ch != ESC);
system("pause");
return 0;
}
Объяснение: