int main(int argc, char *argv[]) { system("chcp 1251 >nul"); setlocale(LC_ALL, "Russian"); int n, s; scanf("%d",&n); int *m = new int[n]; for(int i = 0; i < n; i++) scanf("%d",&m[i]), s += m[i]; int max = m[0], min = m[0], iMax, iMin; for(int i = 0; i < n; i++) { if(m[i] > max) { max = m[i]; iMax = i+1; } } for(int i = n; i; i--) { if(m[i] < min) { min = m[i]; iMin = i+1; } } delete [] m; printf("%d\n%d %d\n%d %d", s, max, iMax, min, iMin); return EXIT_SUCCESS;} 01: #include <iostream> #include <cstdlib>
int main(int argc, char *argv[]) { system("chcp 1251 >nul"); setlocale(LC_ALL, "Russian"); int *m = new int[2]; int sum = 0; scanf("%d%d",&m[0],&m[1]); sum = m[0] + m[1]; delete [] m; printf("%d",sum);
return EXIT_SUCCESS; }
0 votes Thanks 0
Flower1611
ответ неправильный, он не работает в программме с++
Answers & Comments
Verified answer
TGM-GCC 4.9.2 64-bit Release04:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
system("chcp 1251 >nul");
setlocale(LC_ALL, "Russian");
int n, s; scanf("%d",&n);
int *m = new int[n]; for(int i = 0; i < n; i++)
scanf("%d",&m[i]), s += m[i];
int max = m[0], min = m[0], iMax, iMin;
for(int i = 0; i < n; i++)
{
if(m[i] > max)
{
max = m[i];
iMax = i+1;
}
}
for(int i = n; i; i--)
{
if(m[i] < min)
{
min = m[i];
iMin = i+1;
}
}
delete [] m;
printf("%d\n%d %d\n%d %d", s, max, iMax, min, iMin);
return EXIT_SUCCESS;}
01:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
system("chcp 1251 >nul"); setlocale(LC_ALL, "Russian");
int *m = new int[2]; int sum = 0;
scanf("%d%d",&m[0],&m[1]);
sum = m[0] + m[1];
delete [] m;
printf("%d",sum);
return EXIT_SUCCESS;
}
Verified answer
Первый скрин - первая прога, второй - вторая