东华复试OJ每日3题打卡·复盘100~102

基础100:根据一个正整数n,求出从100开始从小到大的第n个纯粹合数。

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


int func(int num){
	if(num<=9)return 0;
	 //0.确定位数
	int len=0;
	for(int i=num;i>0;i/=10){
		len++;
	}
	//1.减数 
	int Jian=1;
	for(int i=1;i<len;i++)Jian*=10;
	
	//2.减掉高位
	while(num>=Jian)num-=Jian;
	return num; 
	
	
}


int main(){
    int n=0;
    char Hang[10];
    
    while( fgets(Hang,sizeof(Hang),stdin) ){
    	n=0;
    	Hang[ strcspn(Hang,"\n")]='\0';
    	for(int i=0;i<strlen(Hang);i++){
    		n = n*10+(Hang[i] - '0');
		}

    	int num=100;
        int count=1;
        while(count < n){
            num++;
            //检测是否为合数
            int Yes=0;//是否为合数
			 
            int temp=num;
            while(temp>0){
            	int HasYinZi=0;
            	if(temp<4){
            		Yes=0;
            		break;
				}
				else {
					for(int i=2;i<=temp/2;i++){
		                if(temp%i==0){
		                    HasYinZi=1;
		                    break;
		                }
            		}
	            	if(HasYinZi==0){
	            		Yes=0;
	            		break;
					}
				}
				if(HasYinZi)Yes=1;
				//去掉高位
				temp = func(temp);
			}//逐位循环 
            if(Yes)count++;
        }//算法
        printf("%d\n",num);
        
    }
}

基础101:输入一串数字,找出其中最长的不超过4个字符的质数子串。若有多个答案,则找出其中数值最大的一个。

cpp 复制代码
//输入一行数字,找到连续数字组成最大的质数

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Check(int num){
	if(num==2||num==3) return 1;
	if(num%2==0)return 0;
	else{
		for(int i=3;i<=num/2;i+=2){
			if(num%i==0)return 0;
		}
		return 1;
	} 
}



int main(){
    //数字串的长度不超过20
    char Hang[30];
    while( fgets(Hang,sizeof(Hang),stdin) ){
        Hang[strcspn(Hang,"\n")] = '\0';
        //printf("%s\n",Hang);
        //辅助变量

        int ans=0;
        //1.遍历每位数字,找到其能与之后数字组成的最长最大质数串
        
        for(int i=0;i<strlen(Hang);i++){
            int temp=(Hang[i] - '0');
            //对单独一个数进行校验 
            if(Check(temp)){
                //如果是质数,则比较是否大于记录
                if(temp>ans){
                    ans = temp;
                }
            }
            for(int j=i+1;j<i+4;j++){
                temp = temp*10 + (Hang[j] - '0');
                //检验是否为质数
                if(Check(temp)){
                    //如果是质数,则比较是否大于记录
                    if(temp>ans){
                        ans = temp;
                    }
                }
            }
        }//遍历每个数字,并构成质数串

        printf("%d\n",ans);
        
    }//每次数据的循环
}

基础102:一串以'@'为结束标志的字符串,从左至右对其进行翻译,若字符串中当前字符是整数n(0≤n≤9),则表示将后一个字符重复n+1次,不论后一个字符是否为数字,且后一个字符无需再次翻译;若当前字符非数字,则表示自己,无需翻译,直接输出即可。

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

int main(){
    char Hang[15];
    while(fgets(Hang,sizeof(Hang),stdin)){
        Hang[strcspn(Hang,"\n")] = '\0';
        int count = 0;
        
        
        int repeat = 0;
        for(int i=0;i<strlen(Hang);i++){
            if(repeat){
            	repeat++;
               while(repeat){
                   printf("%c",Hang[i]);
                   repeat--; 
                   count++;
                   if(count%3==0 && !(i==strlen(Hang)-1 && repeat==0) )printf(" ");
                   
               }
            }
            else{
                if(Hang[i]>='0' && Hang[i]<='9')repeat=Hang[i]-'0';
                else{
                	printf("%c",Hang[i]);
                	count++;
                   if(count%3==0 && !(i==strlen(Hang)-1 && repeat==0) )printf(" ");
				} 
            }
        }
        printf("\n");
    }
}

Computer scientists continue to expand the frontiers of computer and information systems by pioneering the designs of more complex, reliable, and powerful computers; enabling networks of computers to efficiently exchange vast amounts of information; and seeking ways to make computers behave intelligently. As computers become an increasingly integral part of modern society, computer scientists strive to solve new problems and invent better methods of solving current problems.

  • pioneering 开创/引领做先锋,integral 内在的/不可或缺的
  • 计算机科学家们继续探索计算机和信息系统的边界,引领着更复杂、更可信赖、更强大的计算机设计,他们使计算机网络能高效地交换大量信息并探索让计算机表现智能化的方法。随着计算机在现代社会中越来越不可分割,计算机科学家努力解决新问题和发明解决当前问题的更优解。

The goals of computer science range from finding ways to better educate people in the use of existing computers to highly speculative research into technologies and approaches that may not be viable for decades. Underlying all of these specific goals is the desire to better the human condition today and in the future through the improved use of information.

  • speculative 推测的/冒险的、highly speculative 纯理论推测的
  • 计算机科学的目标范围从找到更好地指导人们使用现有计算机的方法,到可能数十年都不可行的技术与方法中进行高度推测性的研究 。隐藏在所有特定目标下的是渴望改善人类当今与未来的境况 通过在未来对信息的使用改进更好地利用信息

Computer science is a combination of theory, engineering, and experimentation. In some cases, a computer scientist develops a theory, then engineers a combination of computer hardware and software based on that theory, and experimentally tests it. An example of such a theory-driven approach is the development of new software engineering tools that are then evaluated in actual use. In other cases, experimentation may result in new theory, such as the discovery that an artificial neural network exhibits behavior similar to neurons in the brain, leading to a new theory in neurophysiology.

  • neurophysiology 神经生理学
  • 计算机科学结合了理论、工程学和实验。在一些情况下,计算机科学家构建理论模型,然后基于该理论设计并构建计算机 硬件和软件的计算机结合体,最后实验测试该机器。这样一个理论驱动的方法的一个例子先开发 新软件工程工具的开发然后在实际使用中 并评估实际使用情况。在其他情况下,实验会引发新理论的发现,例如人工神经网络表现出与大脑里的神经元相似的行为,便催生了神经生理学的新理论
相关推荐
一隅论数智1 天前
给AI一张“业务概念地图“:本体如何从哲学走向企业智能
大数据·人工智能·经验分享·笔记·学习·学习方法·政务
XiHongShi20161 天前
STM32F407 RTC定时器例程,建议保存
stm32·单片机·学习
爱吃苹果的日记本1 天前
离散数学第六课
学习·离散数学
AI职业加油站1 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
旖旎夜光1 天前
力控面试题 01.01: 判定字符是否唯一(位运算) —— 题解
c++·学习·算法·leetcode·力控
奇思妙想聪明勤奋的小羊1 天前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派
人工智能·python·学习·语言模型
霍霍的袁1 天前
【C++】map 和 set 的使用 | 从用法到底层
开发语言·c++·学习·visual studio
彧azz1 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
我爱cope1 天前
【操作系统 | 计算机硬件:CPU、内存与 I/O 如何支撑操作系统?】
学习·操作系统