东华复试OJ每日3题打卡·复盘91~93

基础91:给你一系列的比赛数据(WL形式),分别按照11分制和21分制的比赛规则进行统计,然后输出统计结果。

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

int main(){
    char data[150];
    char hang[30];

    while( fgets(hang,sizeof(hang),stdin) ){
        int length=0;
        int NextHang=0;
        for(int i=0;i<30;i++){
            if(hang[i]=='E')break;
            if(hang[i]=='\0' || hang[i]=='\n'){
                NextHang=1;
                break;
            }
            data[i] = hang[i];
            length++;
        }//确定当前行的位数
        while(NextHang){
        	fgets(hang,sizeof(hang),stdin);//接收第二行拼接完整
        	for(int i=0,j=length;i<30;i++,j++){
        		 if(hang[i]=='\0' || hang[i]=='\n'){
	                NextHang=1;
	                break;
            	}
	            if(hang[i]=='E'){
	            	NextHang=0;
	            	break;	
				}
	            data[j] = hang[i];
	            length++;
       		}
		}
//        for(int i=0;i<length;i++){
//        	printf("%c",data[i]);
//		}//验证 
		
        int Wins=0,Lose=0;

        for(int i=0;i<length;i++){
			//进入新11赛制周期
            if((Wins>=11 && (Wins-Lose)>=2) || (Lose>=11 && (Lose-Wins)>=2)){
            	printf("%d:%d\n",Wins,Lose);

               Wins=0,Lose=0;//恢复数值
			}
            if(data[i]=='W')Wins++;
            if(data[i]=='L')Lose++;
            if(i==length-1)printf("%d:%d\n",Wins,Lose);
            
        }
        printf("\n");
        
        //第二次是21分,0~20为一场
        Wins=0,Lose=0;

		for(int i=0;i<length;i++){
			if((Wins>=21 && (Wins-Lose)>=2) || (Lose>=21 && (Lose-Wins)>=2)){
            	printf("%d:%d\n",Wins,Lose);

               Wins=0,Lose=0;//恢复数值
			}

            if(data[i]=='W')Wins++;
            if(data[i]=='L')Lose++;
            if(i==length-1)printf("%d:%d\n",Wins,Lose);
            
        
		} 
        printf("\n");
        
    }
}

//WWWWWWWWWW LLLLLLLLLLL

基础92:统计出以下四种关系:

(1)在s1或s2中存在的字母(包括在s1和s2中都存在的字母); (2)在s1中且在s2中的字母;

(3)在s1中但不在s2中的字母,在s2中但不在s1中的字母; (4)不在s1中且也不在s2中的字母;

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


int main(){
    //1.输入数据:两个小写字母字符串、长度不超过26个字符、两行
    char s1[26];
    char s2[26];
    
    while(fgets(s1,sizeof(s1),stdin)){
    	fgets(s2,sizeof(s2),stdin);
    	s1[strcspn(s1,"\n")] = '\0';
    	s2[strcspn(s2,"\n")] = '\0';
    	
    	//2.0 辅助变量
    char alphabet[26];
    for(int i=0;i<26;i++){
        alphabet[i] = 'a' + i;
    }
    
    //2.1 在s1或s2中存在的字母;并集
    printf("in s1 or s2:");
    for(int i=0;i<26;i++){
        char key = alphabet[i];
        int countS1 =0;
        int countS2 =0;
        for(int j=0;j<strlen(s1);j++){
            if(key == s1[j]){
                countS1=1;//存在则退出寻找
                break;
            }
        }
        for(int j=0;j<strlen(s2);j++){
            if(key == s2[j]){
                countS2=1;//存在则退出寻找
                break;
            }
        }
        if(countS1 || countS2){
            printf("%c",key);
        }
    }
    printf("\n"); 
    

    //2.2 在s1中且在s2中的字母; 交集
    printf("in s1 and s2:");
    for(int i=0;i<26;i++){
        char key = alphabet[i];
        int countS1 =0;
        int countS2 =0;
        for(int j=0;j<strlen(s1);j++){
            if(key == s1[j]){
            	countS1=1;
            	break;
			}
        }
        for(int j=0;j<strlen(s2);j++){
        	if(key == s2[j]){
        		countS2=1;
        		break;
			}
		}
        if(countS1 && countS2){
            printf("%c",key);//符合则退出遍历下一个字母
        }
    }
    printf("\n"); 

    //2.3 在s1中但不在s2中的字母,在s2中但不在s1中的字母; 

    printf("in s1 but not in s2 ,or in s2 but not in s1:");
    for(int i=0;i<26;i++){
        char key = alphabet[i];
        int countS1 =0;
        int countS2 =0;
        for(int j=0;j<strlen(s1);j++){
            if(key == s1[j]){
            	countS1=1;
            	break;
			}
        }
        for(int j=0;j<strlen(s2);j++){
        	if(key == s2[j]){
        		countS2=1;
        		break;
			}

		}
        if(countS1&&countS2==0 || countS2&&countS1==0){
                printf("%c",key);
        }
    }
	printf("\n"); 
    

    //2.4 不在s1中且也不在s2中的字母;
    printf("not in s1 and s2:");
    for(int i=0;i<26;i++){
        char key = alphabet[i];
        int countS1 =0;
        int countS2 =0;
        for(int j=0;j<strlen(s1);j++){
            if(key == s1[j]){
            	countS1=1;
            	break;
			}
        }
        for(int j=0;j<strlen(s2);j++){
        	if(key == s2[j]){
        		countS2=1;
        		break;
			}

		}
        if(countS1==0&&countS2==0){
            printf("%c",key);
        }
    }
    printf("\n"); 
    	printf("\n"); 
	}
    
    
}

基础93:选择一个字符串S(由L个小写字母组成,5<=L<=100,000),然后他把S顺时针绕成一个圈。如字符串cbadfa,绕成一个圈后,我们认为字符串首尾相连。每次取其中一个字母作为起始字母,并顺时针依次取字母而组成一个字符串。这样将得到一些字符串。我们找到最小的那个字符串,可知为acbadf,也可知道它的第一个字符'a'在原字符串cbadfa中为第6个字符(位置从1开始),将得到的结果6减1得到5,这就是我们需要的口令。

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

int main(){
    int n;
    scanf("%d",&n);
    int len=n;
    n++;//接收字符串长度要加1有换行符 
	getchar();
    char chs[n];
    fgets(chs,sizeof(chs),stdin);
    chs[strcspn(chs, "\n")] = '\0';
    
    int CurrentLen=strlen(chs);
    while(CurrentLen<len){
    	char Hang[n];
    	fgets(Hang,sizeof(Hang),stdin);
    	for(int i=0,j=CurrentLen;i<strlen(Hang);i++,j++,CurrentLen++){
    		if(Hang[i]=='\n')break;
    		chs[j]=Hang[i];
		}
	}
   chs[len] = '\0';
   //printf("输出:%s\n",chs);
	
	
	
	
	
    int ans;
    char AnsChs[n];
    AnsChs[n-1] = '\0';//字符串尾部为结束标志
    for(int i=0;i<n-1;i++){
        AnsChs[i]='z';//初始化tempChs字符串最大值
    }
	 
	char tempChs[n];//每轮得到一个字符串
	tempChs[n-1]='\0' ;
    for(int i=0;i<len;i++){//遍历数组组成的字符串比对得到最小值
        for(int j=i,count=0;count<len;j++,count++){
            tempChs[count]=chs[j%len];

        }
//    printf("%s\n",tempChs);
//    printf("%s\n",AnsChs);
        if( strcmp(tempChs, AnsChs) < 0){
        	//printf("%s\n",tempChs);
//        	printf("%d\n",i);
            ans=i;//ans为最下字符串的起始字符的下标
            strcpy(AnsChs,tempChs);//记录最小字符串
        }
    }
    
    
    

    printf("%d",ans+1-1);//下标比位置小1 
    
}

A digital computer is not a single machine: rather, it is a system composed of five distinct elements: (1) a central processing unit; (2) input devices; (3) memory storage devices; (4) output devices; and (5) communications network, called a bus, which links all the elements of the system and connects the system to the external world.

  • distinct 不同的/独立的
  • 数字计算机不仅仅是一个单一 的机器:相反,它是一个由五个不同部分 组成的系统:(1)一个核心的处理元件,(2)输入设备 ,(3)存储器储存装置,(4)输出设备 ,(5)被称为总线的通信网络将系统的所有组成部分之间以及该系统与外部世界相连接。

A program is a sequence of instructions that tells the hardware of a computer what operations to perform on data. Programs can be built into the hardware itself, or they may exist independently in a form known as software. In some specialized, or "dedicated", computers the operating instructions are embedded in their circuitry; common examples are the microcomputers found in calculators, wristwatches, car engines, and microwave ovens. A general-purpose computer, on the other hand, although it contains some built-in programs (in ROM¹) or instructions (in the processor chip), depends on external programs to perform useful tasks. Once a computer has been programmed, it can do only as much or as little as the software controlling it at any given moment enables it to do. Software in widespread use includes a wide range of applications programs-instructions to the computer on how to perform various tasks.

  • dedicated 专用的,wristwatches 手表, microwave ovens 微波炉,general-purpose 通用的,built-in 内置的/内部的,given moment 特定时刻
  • 程序是指令序列告知计算机硬件对数据执行哪个操作。程序可以在硬件自身内部构建,或是独立存在于被称为软件的形式。在一些特殊或专用情况下,操作指令被嵌入计算机自身的电路中,常见的例子是微型计算机内置在 计算器,手表汽车引擎和微波炉。另一方面,尽管通用计算机包含一些内置的程序或指令,但它依赖于外部的程序来执行有效任务。一旦一个计算机被编程了,它在任何特定时刻能做什么、能做多少,就完全取决于当时控制它的软件 那么它能做的只有软件控制在特定时刻让它做的。软件在普遍使用中包含一系列广泛的应用程序------告诉计算机如何执行各种任务的指令。

There is active research to make computers out of many promising new types of technology, such as optical computers, DNA computers, neural computers, and quantum computers. Most computers are universal, and are able to calculate any computable function, and are limited only by their memory capacity and operating speed. However, different designs of computers can give very different performance for particular problems; for example, quantum computers can potentially break some modern encryption algorithms (by quantum factoring) very quickly.

  • potentially 可能,neural 神经的
  • 人们正在积极研究为了制作出有希望的新技术类型的计算机,例如光计算机,基因计算机,自然计算机和量子计算机。大多数计算机是通用且能任何计算函数的计算,仅仅受限于它们的存储能力和运行速度。然而,计算机不同的设计能对特定问题表现出非常不同的性能,例如量子计算机可能能快速破解一些现代加密算法。
相关推荐
sunshine22 girl1 小时前
Java学习二 基本语法2, 算术运算符
java·学习
衡石科技4 小时前
Data_Agent记忆机制与经验复用衡石分析智能体会话记忆与长期学习技术解析
人工智能·科技·学习·算法·企业级bi
传奇开心果编程5 小时前
【Xilem基础语法学与练】第7课:Xilem与Masonry底层构建技术解析
学习·rust·前端框架
想要入门的程序猿5 小时前
回调函数学习
java·网络·学习
码上上班5 小时前
iptables学习; firewalld学习;ufw学习
学习
RisunJan5 小时前
丝连族谱 0452 — 功能拆解与使用手册
学习
老王爱玩车6 小时前
深入理解指针2
c语言·开发语言·学习
那年窗外下的雪.7 小时前
AIDC 学习日志|第 22 天|All-Active/Single-Active 故障演练设计
服务器·网络·学习·算法·哈希算法
龚寿生7 小时前
23-敏捷开发实战:从Scrum到看板的团队协作方法论
android·学习·scrum·敏捷流程