东华复试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 神经生理学
  • 计算机科学结合了理论、工程学和实验。在一些情况下,计算机科学家构建理论模型,然后基于该理论设计并构建计算机 硬件和软件的计算机结合体,最后实验测试该机器。这样一个理论驱动的方法的一个例子 是先开发 新软件工程工具的开发然后在实际使用中 并评估实际使用情况。在其他情况下,实验会引发新理论的发现,例如人工神经网络表现出与大脑里的神经元相似的行为,便催生了神经生理学的新理论
相关推荐
前进的李工9 小时前
Agent 学习笔记 05:系统提示词应该怎么写
笔记·学习·prompt·agent·个人开发·few-shot·ai应用开发
正在走向自律11 小时前
【3/5】人工智能训练师 三级/高级工 考证学习方向:从“独立执行”到“设计、归因与全链条负责”
人工智能·学习·人工智能训练师·注方案设计·数据质控负责人·模型评测与调优辅助·ai训练项目交付
CCIE-Yasuo13 小时前
网络安全-学习数据库-Mysql-2
数据库·学习·mysql
La Pulga13 小时前
【FreeRTOS源码学习笔记】任务切换
单片机·mcu·学习·嵌入式·freertos·实时操作系统
li星野14 小时前
【学习记录】逻辑分析仪完全入门:从品牌方案到采样率、存储深度的核心概念解析
学习
旖旎夜光14 小时前
【C++ 基础入门】类和对象(上):封装、对象模型与 this 指针
开发语言·c++·笔记·学习
WEI_YANG_JU15 小时前
初中数学教学中合作学习的研究与实践
学习
码农小韩15 小时前
FPGA学习(一)——LED点灯与开发流程
学习·fpga开发·入门·环境配置·仿真·点灯
李长渊哦16 小时前
Qoder 自定义子智能体(Subagent)学习笔记
chrome·笔记·学习
代码山河17 小时前
基本类型转换:自动类型转换与强制类型转换
java·学习·架构·教程·面向对象·项目