C++
C/C++ã®inlineã§ééãããã3ã¤ã®ãã¤ã³ããããã 1ã¤ã¯ãGCCã¯3種é¡ã®ç°ãªãinlineä»æ§ã使ãåãã¦ããã¨ããç¹ã§ããã3種é¡ã¨ã¯ããC++ã®inlineããC90ç¨ã®GCCæ¡å¼µinlineããC99以éã®inlineãã§ããã 2ã¤ç®ã¯ãinlineã使ã£ã¦ããã³ã³ãã¤ã©ãå¿ ãã¤â¦
大éã®å ¥åºåãã¼ã¿ãæ±ã課é¡ã解ãéã«ï¼å ¥åºåã®å¦çã« cin, cout ã¹ããªã¼ã ã使ç¨ãã C++ ããã° ã©ã 㯠scanf, printf é¢æ°ã使ç¨ããåçã®ããã°ã©ã ã«æ¯ã¹ã¦ã¨ã¦ãé ããªããã¨ã«æ³¨æãã¦ã»ããï¼ã㣠ã¦ï¼cin / cout ã¹ããªã¼ã ã使ç¨ãã¦ããã®â¦
2010-07-14 - ã¡ã¢ç¨ç´ã®è£Ubuntu(lucid lynx)+GCC4.4.3ã§ã¯ä»¥ä¸ãå®è¡ããã¨SEGVã æ¡ä»¶ãå¤ãã(é åã§ã¯ãªãvectorã使ããã½ã¼ã対象ã17ãã大ãããã)ã¨ãä»ã®ç°å¢ã§ãSEGVããããã #include <algorithm> bool cmp(int x, int y) { return true; } int main(in</algorithm>â¦
人çãæ¸ãæããè ããããã: 人æç²å¾ä½æ¦ã»ï¼ 試é¨åé¡ã»ã å復深åæ·±ãåªå æ¢ç´¢ã¯ãæ·±ãåªå æ¢ç´¢ã®æ·±ãã®ãªããããå°ããã¤å¢ãããªããè¡ãæ¢ç´¢ã§ãå¹ åªå æ¢ç´¢ã«è¿ãæ§è³ªããã¤æ¢ç´¢ãã²ã¼ã æ¨ã®ããã«æµ ãã¦åºãæ¢ç´¢æ¨ã®å ´åã«ã¡ã¢ãªå¹çãè¯ã好ã¾â¦
人çãæ¸ãæããè ããããã: 人æç²å¾ä½æ¦ã»ï¼ 試é¨åé¡ã»ããä»åº¦ã¯Warshall-Floydã§è§£ãã¦ã¿ããDijkstraãç¹å®ã®2ç¹éã®æççµè·¯ãæ±ããã®ã«å¯¾ãã¦ãWarshall-Floydã¯å ¨ã¦ã®2ç¹éã®æççµè·¯ãä¸æ¬ã§æ±ããã ã¾ãWarshall-Floydã®è¯ãç¹ã¨ãã¦ãè² è¾ºâ¦
試ä½ã¡ãã åºåä¾ ãããã©ããããé£ããã誰ãæã㦠|9|3|5| | |7| |8| | | | |4|5| | | | | | | | |2| |9| |6| | | |6| | |3| | |2| | | | |2|7| | |4| | | | |4| | | |7| | |1| | | | |1|2|4| |9|6| | |2| | |7| | |4| | | | |4| |8|3|9| | | | |6|3|7â¦
dump(1); string s = dump(2);ã¨æ¸ããã¨ãã®åä½ãå¤ããã #include <iostream> #include <sstream> #include <string> using namespace std; template<typename T> class dump_context { private: const T& v; bool flag; public: dump_context(const T& v) : v(v), flag(true) {} ~dump_context(</typename></string></sstream></iostream>â¦
Perlã¨C++ã¯ä¸çä¸ã #!/usr/bin/perl srand(time); my $a = 0; my $b = 0; for(my $i = 0; $i < 1000; $i++) { (rand(2)<1 ? $a : $b) += 1; } print "$a, $b\n" #include <cstdio> #include <cstdlib> #include <time.h> int main(int argc, char **argv) { srand((unsigned)time(NU</time.h></cstdlib></cstdio>â¦
ä»æ¥ããå°ããå ¸åDPãæ±ã£ã¦ã¿ããã¨æããæé·å ±éé¨åæåå(longest common substring)ã¨æé·å ±éé¨åå(longest common subsequence)ãåè ã¯é£ç¶ã¨ããæ¡ä»¶ã¤ãã§ãå¾è ã¯é£ç¶ã§ãªãã¦ãé åºãç¶æããã¦ããã°ããã¨ãããã®ã åè ã¯O( (n+m)min(n,â¦
ã¨ããæ°ããã¦ããã®ã§ãæååæ¤ç´¢ã®æéãªã¼ãããã³åããã¦ã¿ããâ¦æ®éã«ããã§ãããããï¼æéãªã¼ãããã³ã®çæã«ãããæéããã³ã¡ã¢ãªã¯n=ãã¼ãµã¤ãº,c=æåã®ç¨®é¡ã¨ããã¦O(cn)ãªã®ã§ãããã§å°ãé ããã¨ããã©ãæ¤ç´¢ãé常ã«ã·ã³ãã«ã§é«é(â¦
ã ã解説ã¯é¢åãªã®ã§ããªãã maketableããè¦ããã°searchã¯ããã¨å½¢ãä¼¼ã¦ããã®ã§ç°¡åããã #include <cstdio> void kmp_maketable(const char *key, int *table) { table[0]=-1;table[1]=0; int i=2,j=0; while(i==0 || key[i-1]) { if(key[i-1] == key[j]) { </cstdio>â¦
æä½éã ãæ¸ãã¨æ¬¡ã®ããã«ãªãã CXXFLAGS = -O2 -Wall LDFLAGS = -lm all: hello # In Windows, it may be "hello.exe" clean: $(RM) hello CXXFLAGSã¯ãC++ã³ã³ãã¤ã©ã«å¯¾ããå¼æ°ãCã³ã³ãã¤ã©ã«å¯¾ããå¼æ°ã¯CFLAGSãæé©åãè¦åãã¤ã³ã¯ã«ã¼ããã£ã¬â¦
ãåè§ã«åããã¨ã¯ä»¥ä¸ã®ãããªåé¡ã§ããã ãããµã¤ãºã®æ ¼å(å°æ£ç¤ã¿ã¤ã)ãä¸ããããã ãã¹ã«ã¯æ°åãæ¸ããã¦ããããæ¸ããã¦ããªãã æ ¼åå ¨ä½ãé·æ¹å½¢ã®éåã«åå²ããã å ¨ã¦ã®é·æ¹å½¢ã«ã¡ããã©1ã¤ãã¤æ°åãå ¥ãããã¤é·æ¹å½¢ã®é¢ç©ããã®æ°åã¨â¦
Ubuntuã®GCCã¨ãã§ããããã®ãåºãã 解説 ãscanfã®æ»ãå¤ã使ã£ã¦ãªãããâã¤ã¾ããscanfã失æããå ´åã«ã¤ãã¦èãã¦ãªãã³ã¼ããæ¸ãã¦ãããæ°ãã¤ããã¨ããè¦åã 対ç1 scanfã®æ»ãå¤ãæ¤æ»ããã scanfã®æ»ãå¤ã¯ãæåããå¤æ°ã®æ°ããããã¯-1â¦
人çãæ¸ãæããè ããããã: 人æç²å¾ä½æ¦ã»ï¼ 試é¨åé¡ã»ã ã®åé¡ã解ãã¦ã¿ããã¢ã«ã´ãªãºãã¼ã¨ãã¦ã¯ãã®ç¨åº¦ã®åé¡20åã§æ¸ããªãã¨ãã½ã³ã³ç²ååã¨ãã§è¾ããªãã¨æãã®ã§ããã40åã§ã§ãã¾ãããé ã使ã£ã¦è§£ãããã©ããã¯ç¥ãã¾ããããç¥èâ¦
æHiroaki SoftwareããWin32APIã³ã¼ããcuã³ã¼ãã«æ··ãã¦ã³ã³ãã¤ã«ãããã¨ãã¦å¦ãªã¨ã©ã¼ã«å·»ããã¾ãããããã®ã§èª¿æ»ããããCUDAã®ã³ã³ãã¤ã©ã§ããã¨ããã®nvccã¯ã¯ã½ã§ãããã¨ãå¤æãããå ·ä½çã«ã¯ãCreateWindow()ä¸ã«ä¸è¡ã³ã¡ã³ããæ¸ããã¨ãâ¦
ãã¤ãããã¯ã½ã¼ã(bitonic sorter)ã¯ã並åå¦çã«é©ãããã½ã¼ãã£ã³ã°ãããã¯ã¼ã¯ãã¨ãã種é¡ã®ã½ã¼ãã¢ã«ã´ãªãºã ã§ãç´åã§ã®æéè¨ç®éã¯O(n log^2 n)ã§ãããæ大nã§ä¸¦åã§ãã¦ããã®çµæO(log^2 n)ã§è¨ç®ã§ããããã«ãªãã¾ãã ãã¼ã¸ã½ã¼ãã®é¡â¦
/* ãã¼ãã½ã¼ã(heapsort) ãã¼ãæ§é ãç¨ããã½ã¼ãæ¹æ³ ç¹å¾´ 1. ããã®å ´ã(in place)ã§å®è¡ã§ãã(ãã¼ã¸ã½ã¼ãããã±ããã½ã¼ãã¯å¥ã®é åãå¿ è¦ã«ãªã) 2. ææªã§ãO(n log n)ã§å®è¡ã§ãã(ã¯ã¤ãã¯ã½ã¼ãã®ææªã±ã¼ã¹ã¯O(n^2)) 3. ãã£ããã 4. å®å®â¦
åºæ¬ ãã©ã°ã¨ãã¦ä½¿ã£ããããã¨ãã«å¿ é ãªãã¤ã &ã§è«çç© |ã§è«çå ^ã§æä»çè«çå ~ã§ãããå転 a|=bã§ãã©ã°ãç«ã¦ãã a&=~bã§ãã©ã°ãæãã a^=bã§ãã©ã°ãå転ã ã·ãã >>ã§å³ã·ãããç®è¡ã·ãããè«çã·ãããã¯æ±ºã¾ã£ã¦ãªããããã ç®è¡ã·â¦
STLã®std::vectorã®é åã¢ã¯ã»ã¹ã¯at()ã¨operator[]ããã£ã¦ãat()ã§ãªãã¨ç¯å²ãã§ãã¯ãããªããã ãã©ãat()ã¨ãã³ã¼ããæ°æã¡æªããªãã®ã§ä½¿ããããªãããã¨åã«ã¯ããããªããé度ã®åé¡ãæ°ã«ãªã人ããããããããããããããªãããããã°ã®å¿ è¦â¦
ä¸é¨åæè£å®ãã¦ä½ã£ã¦ã¿ãããã®ã½ã¼ã¹ã®åºå ¸ã ãã©ãu8ã¨ãs16ã¨ãã®ååãããLinuxã«ã¼ãã«ãã¨æã£ããã©ã«ã¼ãã«ã«C++使ããªãã®ã§é¢ä¿ãªãã¦ãä»ã«ããããååãæ¢å®ã§å®ç¾©ããã¦ããã®ã¯GBA/NDSããã°ã©ãã³ã°ã£ã½ãã®ã§ããã£ã¡ã¾ããã®ãµã³ãã«â¦