Помогите плиииз=))) у меня есть программа но вней 2 ошибки нужно сделать с помощью динамического массива... // laba4_2.cpp : Defines the entry point for the console application.// #include "stdafx.h"#include "stdio.h"//#include...

Помогите плиииз=))) у меня есть программа но вней 2 ошибки нужно сделать с помощью динамического массива... // laba4_2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" //#include "math.h" using namespace std; int main ( ) { float *a; int i,n; printf("n="); scanf("%i",&n); a=(float*)malloc(N*sizeof(float)); for( i=0; i<=n-1;i++ ) { printf("a[%i]= ",i ); scanf("%i",&a[i]); } for (i=0; i<=N-1; i++) { if (a[i]<0) { printf("oshibka\n"); } else { if (a[i]/2==0) { printf("chetnoe \n"); } else { printf("nechetnoe\n"); } } } return 1; }  
Гость
Ответ(ы) на вопрос:
Гость
Я так понимаю, что вы хотели в программе проверить числа на четность/нечетность, но программа по вашему коду этого не сделает.   В таком виде должно быть без ошибок, но работает по-прежнему неверно:   #include "stdio.h" //#include "math.h" #include using namespace std; int main ( ) { float *a; int i,n; printf("n="); scanf("%i",&n); a=(float*)malloc(n*sizeof(float)); for( i=0; i<=n-1;i++ ) { printf("a[%i]= ",i ); scanf("%i",&a[i]); } for (i=0; i<=n-1; i++) { if (a[i]<0) { printf("oshibka\n"); } else { if (a[i]/2==0) { printf("chetnoe \n"); } else { printf("nechetnoe\n"); } } } system("pause"); return 1; }  
Гость
#include "stdafx.h" #include using namespace std; void main(){ setlocale(0,""); int n; cout<<"Write n\n";cin>>n; int* a = new int[n]; for (int i = 0; i < n; i++) cin>>a[i]; for (int i = 0; i < n; i++) { if (a[i]%2==0) cout<
Не нашли ответ?
Ответить на вопрос
Похожие вопросы