Commit b5e2cdb3 authored by 야오지앙's avatar 야오지앙

Upload New File

parent 2e5f664b
#include<stdio.h>
#include<windows.h>
#include<string.h>
struct Person
{
char name[20];
int age;
}student[3] = { "Steve", 22, "Allen", 20, "Sun", 25 };
int main()
{
int i = 0, j = 0;
char student_name[20];
for (i = 0; i < 3; i++)
{
printf("please input the name of student:\n");
gets_s(student_name, 20);
for (j = 0; j < 3; j++)
{
if ((strcmp(student_name, student[j].name) == 0))
{
student[j].age++;
}
}
}
printf("\nResult:\n");
for (i = 0; i < 3; i++)
{
printf("%5s:%d\n", student[i].name, student[i].age);
}
system("pause");
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment