|
|
вернуться в форумHelp me. Why compilation error? Program work and in my compiler there are 0 warnings and 0 errors... I used DevC++ v.4.9.9.2 #include <stdio.h> int main(void) { int n, i; int cur, cntr;
scanf("%d", &n); int arr[n];
for (i=0; i<n; i++) { scanf("%d", &arr[i]); } for (i=0; i<n-1; i++) { cur = arr[i]; cntr = 0; do { cntr++; i++; } while (cur == arr[i]); printf("%d %d ", cntr, cur); i--; } return 0; } Re: Help me. We can define massiv with n elements such way,when n is const. #include <stdio.h> int main(void) { int n, i; int cur, cntr; scanf("%d", &n); int arr[n];/*<Error here.Write instead of it: int *arr=new int[n];*/ for (i=0; i<n; i++) { scanf("%d", &arr[i]); } for (i=0; i<n-1; i++) { cur = arr[i]; cntr = 0; do { cntr++; i++; } while (cur == arr[i]); printf("%d %d ", cntr, cur); i--; } return 0; } Good luck! Edited by author 06.02.2008 02:55 |
|
|