MaxSubSum - printf( "The file 'crt_fopen_s.c'...

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
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( &quot;The file 'crt_fopen_s.c' was not opened\n&quot; ); else printf( &quot;The file 'crt_fopen_s.c' was opened\n&quot; ); for (i=0;i&lt;N;i++) fscanf_s(stream,&quot;%d&quot;,&amp;A[i]); ThisSum=0; MaxSum=0; for ( j=0; j &lt; N; j++) { ThisSum += A[j]; if (ThisSum &gt; MaxSum) MaxSum = ThisSum; else if ( ThisSum &lt; 0) ThisSum = 0; } fclose(stream); free(A); printf(&quot;%d&quot;, MaxSum); }...
View Full Document

This note was uploaded on 02/16/2011 for the course CS 135 taught by Professor Yuechen during the Fall '08 term at Zhejiang University.

Ask a homework question - tutors are online