• 水题


    1.搜索链表

     http://oj.jxust.edu.cn/contest/problem?id=1644&pid=1

    Problem Description

    从键盘上输入n个学生的信息:学号,姓名, 数学, 英语, 语文的成绩,用这些信息构建一个动态链表。再从键盘上输入一个学号, 用顺序查找的方法在链表中查找该学生的信息。若找到,输出该学生的信息,没有找到,输出No such person

    Input

    输入学生的信息:学号,姓名, 数学, 英语, 语文的成绩, 输入学号为0时终止输入;

    再输入学号进行查询.

    Output

    若找到,输出该学生的信息,成绩保留一位小数,没有找到,输出No such person

    Sample Input

    20130610 Guojin 90.5 89.5 70
    20140612 Huangrong 99.5 100 90.5
    20150548 HuangYaoshi 89 78 56
    0 0 0 0 0
    20140612

    Sample Output

    20140612 Huangrong 99.5 100.0 90.5

    开始用scanf和printf输入输出老错,我日,后来改成cin,cout输入输出就过了;
    补充一个知识点,用cout输出浮点数(要求浮点数保留小数点后一位)方法:
    1 #include <iomanip>
    2 cout<<setiosflags(ios::fixed)<<setprecision(1);
    代码:
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <string>
    #define N 30
    #include <iostream>
    #include <iomanip>
    using namespace std;
    struct node{
    	string sno;
    	string sname;
    	double math;
    	double english;
    	double chinese;
    }student[N];
    
    int main()
    {
    	string mysno,mysname;
    	double mymath,myenglish,mychinese;
    	int i=0,j;
    	while(cin>>mysno>>mysname>>mymath>>myenglish>>mychinese,(mysno!="0"||mysname!="0"||mymath!=0||myenglish!=0||mychinese!=0))
    	{
    		student[i].sno=mysno;
    		student[i].sname=mysname;
    		student[i].math=mymath;
    		student[i].english=myenglish;
    		student[i].chinese=mychinese;
    		i++;
    	}
    	int num=i;
    	cin>>student[i].sno;
    	for(j=0;j<num;j++)
    	{
    		if(student[j].sno==student[i].sno)
    		{
    			cout<<setiosflags(ios::fixed)<<setprecision(1);
    		    cout<<student[j].sno<<" "<<student[j].sname<<" "<<student[j].math<<" "<<student[j].english<<" "<<student[j].chinese;
    			break;
    		 } 
    	 }
    	 if(j>=num) printf("No such person
    ");
    	 return 0; 
    }
    

      



    天晴了,起飞吧
  • 相关阅读:
    asp.net套打
    如何使用哪个asp生成一个excel报表
    自定义打印纸张 c# gdi+ 精确位置打印 套打
    Java调用.dll文件
    [转载].NET实现之(套打解决方案(支持B/S和C/S))
    C#套打
    三十而立,从零开始学ios开发(一):准备起航
    DOTNETBAR的使用方法
    大型网站,要考虑的问题
    AppScan安全漏洞报告
  • 原文地址:https://www.cnblogs.com/jianqiao123/p/11915751.html
Copyright © 2020-2023  润新知