C++程序的小问题
部分功能无法实现是不是局部变量定义问题 试了很久还是不行
下面是写的程序
#include "stdio.h"
#include "conio.h"
void main()
{
int a;
do
{
printf ("1: Introduction\n");
printf ("2: Student transcripts Editor\n");
printf("Enter your choice: ");
scanf("%d",&a);
}while(a<1||a>2);
if(a==1)
{
printf(" Introduction \n");
printf("I just graduated from university students.I am a newcomer to c++\n");
printf("I am learning to improve their level of c++. am very diligent. \n");
printf("I learn good character is sometimes more outward calm.\n");
printf("Sometimes wrote some articles,the English water,proficiency\n ");
printf("to computer,typing soon, to shift to a good sense of service,\n");
printf("work conscientiously stringent, harmony and colleagues,with\n");
printf("a capacity to adapt. to properly deal with contingencies.I\n");
printf("hope that the company can give me a chanceI learn good \n");
printf("character is sometimes more outward calm.Sometimes wrote\n");
printf("some articles, the English water, proficiency to computer,\n");
printf("typing soon, to shift to a good sense of service, work \n");
printf("conscientiously stringent, harmony and colleagues,with a \n");
printf("capacity to adapt. to properly deal with contingencies. I hope\n");
printf("that the company can give me a chance. \n");
}
else if(a==2)
{
struct student
{
char name[20];
int math ;
int physics;
int language;
}students[10];
int i,j;
int sum[10]={0,0,0,0,0,0,0,0,0,0};
char ch;
printf("Enter student data: \n");
for(i=0;i<10;i++)
{
printf("continue(y/n)?");
scanf("%s",ch);
ch=getchar();
if(ch==n)
break;
printf("\n");
printf("name: ");
scanf("%s",students[i].name);
printf("math: ");
scanf("%d",&students[i].math);
printf("physics: ");
scanf("%d",&students[i].physics);
printf("languaage: ");
scanf("%d",&students[i].language);
}
for(j=0;j<i;j++)
{
sum[j]=sum[j]+students[j].math;
sum[j]=sum[j]+students[j].physics;
sum[j]=sum[j]+students[j].language;
}
printf("\n");
for(j=0;j<i;j++)
{
printf("%s",students[j].name);
printf("%d\n",sum[j]);
}
return;
}
getch();
}
追问:那个我写掉了- - 是有 'n'的- -