(急)请问为什么我划线部分的循环根本没有实现

#include<fstream>
#include<iostream>
using namespace std;
struct stu {
    int id, chi, mat, eng, tot;
};
stu a[305];


int main() {
    ifstream infile;//输入流
    ofstream outfile;//输出流
    int i=1;
    int n;
    infile.open("shuju.txt", ios::in);
    if (!infile.is_open())
        cout << "Open file failure" << endl;
    infile >> n;
    int s = n;
    while (0!=n)            // 若未到文件结束一直循环
    {   
        infile >>a[i].chi >> a[i].mat>>a[i].eng;
        a[i].id = i;
        a[i].tot = a[i].chi + a[i].mat + a[i].eng;
        i++;
        n--;
    }
    
    infile.close();

    for (int i = 1; i < n + 1; i++) {
        for (int j = i + 1; j <= n; j++)
        {
            cout << "debug";
            if (a[j].tot > a[i].tot ||
                (a[j].tot == a[i].tot && a[j].chi > a[i].chi) ||
                (a[j].tot == a[i].tot && a[j].chi == a[i].chi && a[j].id < a[i].id)) {
                stu t = a[i]; a[i] = a[j]; a[j] = t;

            }
        }
    };

    outfile.open("jieguo.txt", ios::out);
    if (!outfile.is_open())
        cout << "Open file failure" << endl;
    
    for (int i = 1; i<= s; i++)
        outfile<< a[i].id << " " << a[i].tot << endl;
    outfile.close();
        return 0;
}

要看循环控制语句里面,变量:n的值最后变成了什么呀

循环没执行,肯定是因为没有进去循环哦,你选输出一下变量:n的值看一下吧