OpenJ_Bailian - 2800 垂直直方图

一级标题 OpenJ_Bailian 2800 垂直直方图

题目

在这里插入图片描述
博主学不会C++,用纯C怒打200多行!
思路就是全部排列!!!!!

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  char a[100];
  int i,j;
  int count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0,count10=0,count11=0;
  int len;
  int count12=0,count13=0,count14=0,count15=0,count16=0,count17=0,count18=0,count19=0,count20=0,count21=0,count22=0;
  int sum=4;
  int count23=0,count24=0,count25=0,count26=0;
 ///统计 
  while(sum--) 
 {  
 	len=0;
	 gets(a);
    len=strlen(a);
    for(i=0;i<len;i++)
    {
    	if(a[i]=='A')
    	count1++;
    	else if(a[i]=='B')
    	count2++;
		else if(a[i]=='C')	count3++;
		else if(a[i]=='D')	count4++;
		else if(a[i]=='E')	count5++;
		else if(a[i]=='F')	count6++;
		else if(a[i]=='G')	count7++;
		else if(a[i]=='H')	count8++;
		else if(a[i]=='I')	count9++;
		else if(a[i]=='J')	count10++;
		else if(a[i]=='K')	count11++;
		else if(a[i]=='L')	count12++;
		else if(a[i]=='M')	count13++;
		else if(a[i]=='N')	count14++;
		else if(a[i]=='O')	count15++;
		else if(a[i]=='P')	count16++;
		else if(a[i]=='Q')	count17++;
		else if(a[i]=='R')	count18++;
	    else if(a[i]=='S')	count19++;
	    else if(a[i]=='T')	count20++;
	    else if(a[i]=='U')	count21++;
	    else if(a[i]=='V')	count22++;
	    else if(a[i]=='W')	count23++;
	    else if(a[i]=='X')	count24++;
	    else if(a[i]=='Y')	count25++;
	    else if(a[i]=='Z')	count26++;
	}
}
///比大小// 
	int max1=count1>count2?count1:count2;
	int max2=max1>count3?max1:count3;
	int max3=max2>count4?max2:count4;
	int max4=max3>count5?max3:count5;
	int max5=max4>count6?max4:count6;
	int max6=max5>count7?max5:count7;
	int max7=max6>count8?max6:count8;
	int max8=max7>count9?max7:count9;
	int max9=max8>count10?max8:count10;
	int max10=max9>count11?max9:count11;
	int max11=max10>count12?max10:count12;
	int max12=max11>count13?max11:count13;
	int max13=max12>count14?max12:count14;
	int max14=max13>count15?max13:count15;
	int max15=max14>count16?max14:count16;
	int max16=max15>count17?max15:count17;
	int max17=max16>count18?max16:count18;
	int max18=max17>count19?max17:count19;
	int max19=max18>count20?max18:count20;
	int max20=max19>count21?max19:count21;
	int max21=max20>count22?max20:count22;
	int max22=max21>count23?max21:count23;
	int max23=max22>count24?max22:count24;
	int max24=max23>count25?max23:count25;
	int max25=max24>count26?max24:count26;
/打印图形 

		for(i=0;i<max25;i++)
		{
			
			for(j=0;j<1;j++)
			{ 
			   if(i<max25-count1)
			   cout<<" ";
			   else
				cout<<"*";
			}
			for(j=1;j<2;j++)
			{   
			   if(i<max25-count2)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=2;j<3;j++)
			{   
			   if(i<max25-count3)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=3;j<4;j++)
			{   
			   if(i<max25-count4)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=4;j<5;j++)
			{   
			   if(i<max25-count5)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=5;j<6;j++)
			{   
			   if(i<max25-count6)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=6;j<7;j++)
			{   
			   if(i<max25-count7)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=7;j<8;j++)
			{   
			   if(i<max25-count8)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=8;j<9;j++)
			{   
			   if(i<max25-count9)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=9;j<10;j++)
			{   
			   if(i<max25-count10)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=10;j<11;j++)
			{   
			   if(i<max25-count11)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=11;j<12;j++)
			{   
			   if(i<max25-count12)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=12;j<13;j++)
			{   
			   if(i<max25-count13)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=13;j<14;j++)
			{   
			   if(i<max25-count14)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=14;j<15;j++)
			{   
			   if(i<max25-count15)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=15;j<16;j++)
			{   
			   if(i<max25-count16)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=16;j<17;j++)
			{   
			   if(i<max25-count17)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=17;j<18;j++)
			{   
			   if(i<max25-count18)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=18;j<19;j++)
			{   
			   if(i<max25-count19)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=19;j<20;j++)
			{   
			   if(i<max25-count20)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=20;j<21;j++)
			{   
			   if(i<max25-count21)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=21;j<22;j++)
			{   
			   if(i<max25-count22)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=22;j<23;j++)
			{   
			   if(i<max25-count23)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=23;j<24;j++)
			{   
			   if(i<max25-count24)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=24;j<25;j++)
			{   
			   if(i<max25-count25)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			for(j=25;j<26;j++)
			{   
			   if(i<max25-count26)
			    cout<<"  ";
			    else
				cout<<" *";
			}
			
			cout<<"\n"; 
		}	   
	   cout<<"A"<<' '<<"B"<<' '<<"C"<<' '<<"D"<<' '<<"E"<<' '<<"F"<<' '<<"G"<<' '<<"H"<<' '<<"I"<<' '<<"J"<<' '<<"K"<<' '<<"L"<<' '<<"M"<<' '<<"N"<<' '<<"O"<<' '<<"P"<<' '<<"Q"<<' '<<"R"<<' '<<"S"<<' '<<"T"<<' '<<"U"<<' '<<"V"<<' '<<"W"<<' '<<"X"<<' '<<"Y"<<' '<<"Z";
	   
	
  

return 0;	
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值