猫史档案馆


c++代码(你要下载c++)

用户:我超级爱编程我超级爱编程查看:8 回复:8 评论:8 创建时间:2024-04-08T17:27:19


做了一个人 

#include <iostream>
#include <windows.h>
int main()
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 6);
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}	
		std::cout<<"  *";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<" ***";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<"  *";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<"*****";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<"  *";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<" * *";
		std::cout<<"\n";
		for(int j=1;j<=i;j++)
		{
			std::cout<<" ";
		}
		std::cout<<"*   *";
		Sleep(100);
		std::system("cls");
	}
}

再见ヾ( ̄▽ ̄)Bye~Bye~


回复

上一页1 页 / 共 1下一页
Data_CatyData_Caty

《人》

点赞1


评论


不取辣不取辣

我根本不用下载C++,因为我的文本编辑器是VSC

点赞0


评论


一束耀眼的光芒一束耀眼的光芒

so,有什么用

点赞0


评论


root㉿ikunliroot㉿ikunli

a?imgsrc="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/5c/yw_thumb.gif"alt="emotion_疑问"

点赞0


评论


bcm官方bcm官方

我做的(很久以前的,现在看起来:喵)

#include<iostream>
using namespace std;
int main(){
	int c=5,a[c*c]={0,0,0,2,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0},x=5,y=4;
	char f;
	while(a[5*(y-1)+x-1]!=2){
		for(int Y=1;Y<=c;Y++){
			for(int X=1;X<=c;X++){
				if(X==x and Y==y){
					cout<<"我";
				}else if(a[5*(Y-1)+X-1]==2){
					cout<<"az";
				}else if(a[5*(Y-1)+X-1]==1){
					cout<<"  ";
				}else{
					cout<<"墙";
				}
			}
			cout<<"\n";
		}
		cin>>f;
		if(f=='w'){
			y--;
		}else if(f=='s'){
			y++;
		}else if(f=='a'){
			x--;
		}else if(f=='d'){
			x++;
		}
		if(a[5*(y-1)+x-1]==2){
			cout<<"win\n\n\n\n\n";
			break;
		}else if(a[5*(y-1)+x-1]==0){
			cout<<"game over\n\n\n\n\n";
			break;
		}
	}
	while(true){
		c=1;
	}
}

(走迷宫,须要裁一下执行框)

点赞0


评论


编程喵呀编程喵呀

以前做的猜数字(c++)

上代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    printf("猜数字(100以内10次机会)\n");
    int a,b,c,d,e;
    int i,j;
    int k[99];
    srand((unsigned int) time(0));
    for(i=0;i<9;i++)
    {
        b=k[i]=rand()%100;
    }
    for(i=1;i<=10;i++)
    {
        printf("第%d次:\n",i);
        printf("猜一个数字:\n");
        scanf("%d",a);
        if(a>b)
        {
            printf("太大了\n\n");
        }
        if(a<b)
        {
            printf("太小了\n\n");
        }
        if(a==b)
        {
            printf("猜对了!\n")
            return 0;
        }
    }
    printf("\n失败了\n")
    return 0;
}

点赞1


评论


imgainary_numberimgainary_number

#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int cu,go;
int player_x=5,player_y=1;
int s[100] = {
	1,1,1,1,1,1,1,1,1,1,
	3,0,0,1,0,0,1,0,0,1,
	1,1,0,1,1,0,1,1,0,1,
	1,1,0,0,1,0,0,0,0,1,
	1,0,1,0,1,1,0,1,1,1,
	1,0,1,0,1,1,0,1,0,1,
	1,0,1,0,0,0,0,0,0,1,
	1,0,1,1,0,1,0,1,1,1,
	1,0,0,0,0,1,0,0,0,1,
	1,1,1,1,1,1,1,1,1,1
};
void player_move(int speed){
	int c = _getch();
	if (c=='d'){
		player_y+=speed;
		cu = (player_y+1)*10+player_x;
		if(s[(player_y+1)*10 + player_x] == 3){
			go = 1;
		}
		else { 
			go = 0;
		}
		if (s[cu]!=1){
			s[player_y*10+player_x] = 0;
			s[cu] = 2;
		}
		else {
			player_y-=speed;
		}
	}
	if (c=='a'){
		player_y-=speed;
		cu = (player_y+1)*10+player_x;
		if(s[(player_y+1)*10 + player_x] == 3){
			go = 1;
		}
		else { 
			go = 0;
		}
		if (s[cu]!=1){
			s[(player_y+2)*10+player_x] = 0;
			s[cu] = 2;
		}
		else {
			player_y+=speed;
		}
	}
	if (c=='s'){
		player_x+=speed;
		cu = (player_y+1)*10+player_x;
		if(s[(player_y+1)*10 + player_x] == 3){
			go = 1;
		}
		else { 
			go = 0;
		}
		if (s[cu]!=1){
			s[(player_y+1)*10+player_x-1] = 0;
			s[cu] = 2;
		}
		else {
			player_x-=speed;
		}
	}
	if (c=='w'){
		player_x-=speed;
		cu = (player_y+1)*10+player_x;
		if(s[(player_y+1)*10 + player_x] == 3){
			go = 1;
		}
		else { 
			go = 0;
		}
		if (s[cu]!=1){
			s[(player_y+1)*10+player_x+1] = 0;
			s[cu] = 2;
		}
		else {
			player_x+=speed;
		}
		
	}
}

void render(){
	system("cls");
	for (int x = 0;x!=10;++x){
		cout<<s[x];
		for(int y = 0; y!=10;++y){
			cout<<s[(y+1)*10+x];
		}
		cout << " "<< "\n";
	}
}

int main(){
	while (go==0){
		if(go == 0){
			player_move(1);
			render();
			cout << "x:" << player_x << " | y:" << player_y << "\n";
		}
	}
	cout << "Äã¹ý¹Ø!";
	return 0;
}

炫技()()())(()()(

点赞0


评论


Data_CatyData_Caty

真题:换零钱(真正的炫技)

输入不同硬币面值数k,凑的钱数n和k个不同面值的硬币

输出最少硬币数,凑不出则输出-1

#include<bits/stdc++.h>
using namespace std;
int k,n,a[1009],mem[1009],dp[1009];
int main() {
	cin >> k >> n;
	for(int i=1; i<=k; i++) {
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		dp[i]=1e9-2;
	}
	for(int i=1;i<=n;i++){
		int minn=1e9;
		for(int j=1;j<=k;j++){
			if(i<a[j]){
				continue;
			}
			minn=min(minn,dp[i-a[j]]+1);
		}
		dp[i]=minn;
	}
	if(dp[n]>=1e9-2){
		cout << "-1";
	}else{
		cout << dp[n];
	}
	return 0;
}

点赞0


评论