东华复试OJ每日3题打卡·复盘94~96

基础94::输入两串字符串s和subs,求s中subs的起始位置。

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
    char s1[100];
    char s2[100];

    while( fgets(s1,sizeof(s1),stdin) ){
    	fgets(s2,sizeof(s2),stdin);
        s1[ strcspn(s1,"\n")]='\0';
        s2[ strcspn(s2,"\n")]='\0';
        int ans=0;
        int Yes=1;
        for(int i=0;i<100-strlen(s2);i++){
			Yes=1;
            for(int j=i,k=0;j<i+strlen(s2);j++,k++){
                if(s1[j] != s2[k]){
                    Yes=0;
                    break;
                }
            }//对比子串
            if(Yes){
                ans = i+1;
                printf("%d\n",ans);
                break;
            }
        }//遍历数组
        if(Yes==0)printf("0\n");
        
        
    }
    
}

基础95:在一行英文单词中,找出其中最长的单词(若有多个最长,找出第一个出现的),并输出这个单词的长度。

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(){
    //0. 按行接收并处理
    char Hang[1000];
    while( fgets(Hang,sizeof(Hang),stdin) ){
        Hang[ strcspn(Hang,"\n") ] = '\0';
        char word[300];//记录最长单词
        int length=0;//记录最大长度

        char TempWord[300]; 
        int Templength=0;

        //遍历字符串
        for(int i=0,j=0;i<1000;i++){
            if(Hang[i] == ' ' || Hang[i] == '\0'){//遇到空格时结算已记录的单词
                TempWord[j] = '\0';
                if(Templength>length){
                	//printf("%s\n",TempWord);
                    length = Templength; //保存长度
                    for(int k=0;k<300;k++){//保存单词
                        if(TempWord[k] == '\0'){
                            word[k] = '\0';
                            //printf("%s\n",word);
                            break;
                        }
                        word[k] = TempWord[k];
                    }
                }
                if(Hang[i] == '\0')break;
                //恢复记录
                j=0;
                Templength=0;
            }//结算
            else {
                TempWord[j] = Hang[i];
                Templength++;
                j++;
            }
        }//遍历字符串
        printf("%d %s\n",length,word);
    }//大循环
    
}

基础96:

发放的奖学金共有五种,获取的条件各不相同:

  1. 院士奖学金:每人8000元,期末平均成绩高于80分,并且在本学期内发表1篇或1篇以上论文的学生均可获得。

  2. 五四奖学金:每人4000元,期末平均成绩高于85分,并且班级评议成绩高于80分的学生均可获得。

  3. 成绩优秀奖:每人2000元,期末平均成绩高于90分的学生均可获得。

  4. 西部奖学金:每人1000元,期末平均成绩高于85分的西部省份学生均可获得。

  5. 班级贡献奖:每人850元,班级评议成绩高于80分的学生干部均可获得。

只要符合条件就可以得奖。 每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。

例如明明的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。

由于老师在学期末的时候很忙,所以,他把奖学金统计的事情交给明明做。老师把考试的相关数据给了明明,让他统计出以下数据:

1) 哪位同学获得的奖学金最多;

2) 获得最多奖学金的同学一共获得了多少奖学金;

3) 所有获得奖学金的同学一共获得了多少奖学金;

cpp 复制代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 


int main(){
    int num;
    while(scanf("%d",&num) != EOF){
        getchar();//回收输入num后的回车
        
        //0. 辅助变量
        int sum=0;//奖金总额
        int max=0;//单人最大奖金
        char name[30];//该姓名


        //1.0 对每个字符串进行处理
        while(num){//
            //1.1 接收num个字符串
             //姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数
            char Hang[50];
            fgets(Hang,sizeof(Hang),stdin);
            Hang[ strcspn(Hang,"\n") ] = '\0';
            int index;
            char TempName[30];
            for(int i=0;i<50;i++){
                if(Hang[i] == ' '){
                   index = i;
                    break;
                }
                TempName[i] = Hang[i];
            }//1.2获取姓名
            TempName[index] = '\0';
            
            //1.3 期末平均成绩
            int ExamScore=0;
            for(int i=index+1;i<50;i++){//index为空格位置
                if(Hang[i] == ' '){
                   index = i;
                    break;
                }
                ExamScore = ExamScore*10 +  (Hang[i] - '0');
            }//获取期末成绩

            //1.4 班级评议成绩
            int ClassScore=0;
            for(int i=index+1;i<50;i++){//index为空格位置
                if(Hang[i] == ' '){
                   index = i;
                    break;
                }
                ClassScore = ClassScore*10 +  (Hang[i] - '0');
            }//获取班级评议成绩

            //1.5 是否是学生干部
            int StudenDE;
            for(int i=index+1;i<50;i++){//index为空格位置
                if(Hang[i] == ' '){
                   index = i;
                    break;
                }
                if(Hang[i] == 'Y')StudenDE=1;
                if(Hang[i] == 'N')StudenDE=0;
            }

            //1.6 是否是西部省份学生
            int West;
            for(int i=index+1;i<50;i++){
                if(Hang[i] == ' '){
                   index = i;
                    break;
                }
                if(Hang[i] == 'Y')West=1;
                if(Hang[i] == 'N')West=0;
            }
            //1.7  发表的论文数           
            int Paper=0;
            for(int i=index+1;i<50;i++){
                if(Hang[i] == '\0' ){
                   index = i;
                    break;
                }
                Paper = Paper*10 +  (Hang[i] - '0');
            }

//			printf("%s + %d + %d\n",TempName,ExamScore,Paper);//验证 
//			printf("%d + %d",StudenDE,West) ;
            
            //2.计算 
            int prize=0;
			if(ExamScore >80 && Paper>=1) prize+=8000;
			if(ExamScore > 85 && ClassScore>80)prize+=4000;
			if(ExamScore > 90)prize+=2000;
			if(ExamScore > 85 && West==1)prize+=1000;
			if(ClassScore >80 && StudenDE==1)prize+=850;
			if(prize > max){
				//printf("发生更新:%s\n",TempName);
				for(int i=0;i<30;i++){
					name[i] = TempName[i];
					if(TempName[i] == '\0')break;	
				}
				//printf("更新之后:%s\n",name);
				max = prize;
			}
			sum += prize;
			
			num--;
			if(num == 0){
				printf("%s\n",name);
				printf("%d\n",max);
				printf("%d\n",sum);
				printf("\n") ;
			}
        }
        
    }
    
    
    
    
}

A computer will solve problems in exactly the way it is programmed to, without regard to efficiency, alternative solutions, possible shortcuts, or possible errors in the code. Computer programs that learn and adapt are part of the emerging field of artificial intelligence and machine learning. Artificial intelligence-based products generally fall into two major categories: rule-based systems and pattern recognition systems. Rule-based systems attempt to represent the rules used by human experts and tend to be expensive to develop. Pattern-based systems use data about a problem to generate conclusions. Examples of pattern-based systems include voice recognition, font recognition, translation and the emerging field of on-line marketing.

  • shortcut 捷径
  • 计算机通过编程解决问题会严格按照被编程的方式解决问题, 而不考虑效率、替选方案、可能的捷径或代码中可能的故障。计算机编程中的学习和适应学习和适应计算机程序 是结合人工智能和机器学习相结合的领域的一部分。基于人工智能的产品普遍分为两个大类:基于规则的系统和模式识别系统。基于规则的系统试图模拟 人类专家使用的规则和开发成本 往往过于昂贵而无法构建。基于模式的系统使用与问题有关的数据来产生结论。基于模式的系统案例包括语音识别、字体识别、翻译和新兴领域线上交易在线营销

Computers will become more advanced and they will also become easier to use. Improved speech recognition will make the operation of a computer easier. Virtual reality (虚拟现实), the technology of interacting with a computer using all of the human senses, will also contribute to better human and computer interfaces (界面,接口). Other, exotic (奇异的) models of computation are being developed, including biological computing that uses living organisms, molecular (分子的) computing that uses molecules with particular properties, and computing that uses deoxyribonucleic acid (DNA), the basic unit of heredity (遗传), to store data and carry out operations. These are examples of possible future computational platforms that, so far, are limited in abilities or are strictly theoretical. Scientists investigate them because of the physical limitations of miniaturizing (使小型化) circuits embedded in silicon. There are also limitations related to heat generated by even the tiniest of transistors.

  • properties 属性/性质,tiniest 最小的
  • 计算机将会更高级且变得易于使用。提升了的语音识别将使得计算机的运行更轻松。虚拟现实是一项使用人类全部感官来与计算机互动的技术,这将会促使人机界面变得更好。其他的奇特的 计算模型正在开发,包括使用了活有机体的生物计算、使用具有特定性质的分子的分子计算、和使用了基本遗传单元DNA来存储数据和承担操作的计算。这些都是未来计算平台的可能案例,到目前为止,这些计算模型都能力有限停留在理论层面 。由于嵌入在硅基板上的小型化电路的物理限制,科学家正在探索这些计算模型。此外, 也有和即使是 极小的晶体管也会产生的热量相关的限制。

Computer science is the study of the theory, experimentation, and engineering that form the basis for the design and use of computers devices that automatically process information. Computer science traces its roots to work done by English mathematician Charles Babbage, who first proposed a programmable mechanical calculator in 1837. Until the advent of electronic digital computers in the 1940s, computer science was not generally distinguished as being separate from mathematics and engineering. Since then it has sprouted numerous branches of research that are unique to the discipline.

  • 计算机科学是一个对构成自动信息处理设备的设计与使用基础的 理论、实验和工程学 的研究,形成对计算机即自动处理信息的装置的设计和使用的基础。追踪计算机科学的根茎根源可追溯到 是由英国数学家查尔斯·巴贝奇所确立的,他在1837年首次提出可编程机械式计算器。直到在20世纪40年代电子数字计算机的到来前,计算机科学没有从数学和工程学中区分开来。自从计算机科学萌芽出无数该学科所独有的 研究分支,便成了独一无二的学科。
相关推荐
be or not to be2 小时前
假期js学习汇总
前端·javascript·学习
寒秋花开曾相惜2 小时前
(学习笔记)2.2 整数表示(2.2.6 扩展一个数字的位表示)
c语言·开发语言·笔记·学习
别退2 小时前
brain
科技·学习
宇木灵2 小时前
C语言基础-八、结构体和共同(用)体
c语言·开发语言·数据结构·笔记·学习·算法
宇木灵3 小时前
C语言基础-九、动态内存分配
c语言·开发语言·学习·算法
楼田莉子3 小时前
Linux网络学习:网络的基础概念
linux·运维·服务器·网络·c++·学习
im_AMBER3 小时前
Leetcode 126 两数之和 II - 输入有序数组 | 盛最多水的容器
数据结构·学习·算法·leetcode
科技林总3 小时前
【系统分析师】9.6 安全管理措施
学习
啊阿狸不会拉杆3 小时前
《计算机视觉:模型、学习和推理》第 7 章-复杂数据密度建模
人工智能·python·学习·算法·计算机视觉·t分布·复杂数据密度建模