我写了个程序,每次运行EXE时,对话框会自动关闭,难道有死循环吗?
请各位高手帮忙看看
#include <stdio.h>
int main()
{
int t[81];
char s[81][20];
int i=0,j,k,n,m,p,flag;
printf("please input the name and score of the student\n");
scanf("%s,%d",s[i][20],t[i]);
while(s[i][20]&&t[i])
{
i++;
scanf("%s,%d",s[i][20],&t[i]);
}
for(j=0;j<i&&flag;j++)
{
flag=0;
for(k=0;k<i-j;k++)
if(t[k]>t[k+1])
{
n=t[k],t[k]=t[k+1],t[k+1]=n;
m=s[k][20],s[k][20]=s[k+1][20],s[k+1][20]=m;
flag=1;
}
}
for(p=0;p<=i;p++)
printf("the score of %s is %d.\n",s[p][20],t[p]);
}
请各位高手帮忙看看
#include <stdio.h>
int main()
{
int t[81];
char s[81][20];
int i=0,j,k,n,m,p,flag;
printf("please input the name and score of the student\n");
scanf("%s,%d",s[i][20],t[i]);
while(s[i][20]&&t[i])
{
i++;
scanf("%s,%d",s[i][20],&t[i]);
}
for(j=0;j<i&&flag;j++)
{
flag=0;
for(k=0;k<i-j;k++)
if(t[k]>t[k+1])
{
n=t[k],t[k]=t[k+1],t[k+1]=n;
m=s[k][20],s[k][20]=s[k+1][20],s[k+1][20]=m;
flag=1;
}
}
for(p=0;p<=i;p++)
printf("the score of %s is %d.\n",s[p][20],t[p]);
}