- #include <iostream>
- #include <vector>
- using namespace std;
- const int MAX =1010;
- int n; // so luong cv
- int a[MAX]; // ma trận cv
- int P1=0;
- int P2=0;
- int P3=0;
- int CH2_VD3b(){
- for (int i=0;i<n;i++){
- if(P1<=P2 && P1<=P3){
- P1+=a[i];
- }
- else if (P2<=P1 && P2<=P3){
- P2+=a[i];
- }
- else if (P3<=P1 && P3<=P2) {
- P3+=a[i];
- }
- }
- int result;
- if (P1>P2) result = P1;
- else result = P2;
- if (result<P3) result=P3;
- return result;
- }
- int main() {
- char *s = (char*)"D:\\C-C++\\csttnt\\schedulea.txt";
- FILE *f=fopen(s,"r+");
- if(f == NULL)
- {
- printf("Error!");
- exit(1);
- }
- fscanf(f,"%d",&n);
- for (int i = 0; i < n; i++) {
- fscanf(f,"%d",&a[i]);
- // nhập ma trận kế cận
- }
- fclose(f);
- cout<< CH2_VD3b(
Raw Paste