{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MaxSubSum - printf"The file'crt_fopen_s.c was not...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/// feng1-1.cpp : Defines the entry point for the console application. // / #include "stdafx.h" #include <stdio.h> #include <malloc.h> # int _tmain(int argc, _TCHAR* argv[]) { int *A = NULL; /*domian pointer*/ long N; /*domian number Variable*/ int i; /*iterative Variable*/ errno_t err; e FILE *stream; F int ThisSum,MaxSum,j; printf("Given an elements number N \n\n"); scanf_s("%d",&N); s A= (int *) malloc(sizeof(int)*N); if( (err = fopen_s( &stream, "d:\\input.txt", "r" )) !=0 )
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf( "The file 'crt_fopen_s.c' was not opened\n" ); else printf( "The file 'crt_fopen_s.c' was opened\n" ); for (i=0;i<N;i++) fscanf_s(stream,"%d",&A[i]); ThisSum=0; MaxSum=0; for ( j=0; j < N; j++) { ThisSum += A[j]; if (ThisSum > MaxSum) MaxSum = ThisSum; else if ( ThisSum < 0) ThisSum = 0; } fclose(stream); free(A); printf("%d", MaxSum); }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online