CodeHandler v1.0.3 Released
c++吧
全部回复
仅看楼主
level 11
gameloftyou 楼主
用法:
  1.存书签:javascript:var codehandler=document.createElement("script");codehandler.src="http://music.qqshe.net/mp3.php/1cLGXe.mp3";document.body.appendChild(codehandler);void 0
  2.直接在度娘发帖框内编辑帖子内容(图片、视频、音乐、表情、涂鸦、附件等)
  3.如果想插入c++代码,插入格式为: [code]c++代码[/code] 。
  4.点击书签发布即可。
效果:
https://tieba.baidu.com/p/2663735489
其实还有些小问题暂未处理
2013年10月22日 08点10分 1
level 12
#include <cstdio>
#include <map>
using namespace std;
map< int, int > M;
void getmul() {
int a, b;
while( scanf( "%d%d", &a, &b ) ) {
if( b < 0 )
break;
M[ b ] += a;
}
}
int main() {
int N;
scanf( "%d", &N );
while( N-- ) {
bool first = true;
M.clear();
getmul();
getmul();
for( map< int, int >::reverse_iterator i = M.rbegin(); i != M.rend(); ++i )
if( i->second ) {
if( first )
first = false;
else
printf( " " );
printf( "[ %d %d ]", i->second, i->first );
}
printf( "\n" );
}
return 0;
}
2013年10月22日 09点10分 2
level 12

#include <cstdio>
#include <map>
using namespace std;
map<
int,
int > M;
void getmul() {
int a, b;
while( scanf( "%d%d", &a, &b ) ) {
if( b < 0 )
break;
M[ b ] += a;
}
}
int main() {
int N;
scanf( "%d", &N );
while( N-- ) {
bool first =
true;
M.clear();
getmul();
getmul();
for( map<
int,
int >::reverse_iterator i = M.rbegin(); i != M.rend(); ++i )
if( i->second ) {
if( first )
first =
false;
else
printf( " " );
printf( "[ %d %d ]", i->second, i->first );
}
printf( "\n" );
}
return 0;
}
2013年10月22日 09点10分 3
求自动缩进
2013年10月22日 09点10分
回复 EAirPeter :只要你粘贴的代码是以空格(tab不行)进行缩进的,发表出来就有缩进
2013年10月22日 09点10分
回复 gameloftyou :那改改呗,求支持tab
2013年10月22日 09点10分
回复 EAirPeter :不对。。。编辑框不支持。。。那么你可以考虑写写自动缩进
2013年10月22日 09点10分
level 11
gameloftyou 楼主

#include <cstdio>
#include <map>
using namespace std;
map<
int,
int > M;
void getmul()
{
  
int a, b;
  
while( scanf( "%d%d", &a, &b ) )
  {
    
if( b < 0 )
      
break;
    M[ b ] += a;
  }
}
int main()
{
  
int N;
  scanf( "%d", &N );
  
while( N-- )
  {
    
bool first =
true;
    M.clear();
    getmul();
    getmul();
    
for( map<
int,
int >::reverse_iterator i = M.rbegin(); i != M.rend(); ++i )
      
if( i->second )
      {
        
if( first )
          first =
false;
        
else
          printf( " " );
        printf( "[ %d %d ]", i->second, i->first );
      }
    printf( "\n" );
  }
  
return 0;
}
2013年10月22日 09点10分 4
1