编写C++程序代码,求大神解答

 

代码如下,如有帮助,请采纳一下,谢谢。

#include <stdio.h>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
	char name[20];
	char pwd[20];
	char xuhao[12];
	
	string info[100];  //存储所有学生信息
	string strCom = "2020015";
	int i;
	char * p;
	char tmp[20] = {0};

	while(true)
	{
		printf("请输入用户名:");
		scanf("%s",name);
		if (strcmp(name,"zhangsan") == 0)
		{
			break;
		}else
			printf("用户名错误\n");
	}
	while(true)
	{
		printf("请输入密码:");
		scanf("%s",pwd);
		if (strcmp(pwd,"zs") == 0)
		{
			break;
		}else
			printf("密码错误\n");
	}
	
	//初始化数组2020015 832 734
	for (i = 734; i <= 832; i++)
	{
		p = itoa(i,tmp,10);
		info[i-734] = strCom + tmp;
	}

	printf("请输入本人学号:");
	scanf("%s",xuhao);
	for (i = 0; i < (832- 734+1); i ++)
	{
		if (info[i].compare(xuhao) == 0)
		{
			printf("排在第%d位\n",i+1);
			break;
		}
	}
	//getchar();
	//getchar();
	return 0;
}

 

题目只说明了学号,并没有提供姓名,密码是哪里来的,怎么判断输入正确呢?

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632