3と3のばいすーはあほになるの元ネタ知りませんでした。。
http://q.hatena.ne.jp/1207585413
http://codepad.org/oKdE0Xsq codepad itoa つかえねーよ('A`)わーん
char *itoa( const int num ,char* buf, const int ignore ) { const char table[] = "0123456789"; char *p = buf; int tmp; for(tmp=num;tmp>0;tmp /= 10) *p++; *p='\0'; for(tmp=num;tmp>0;tmp /= 10) *--p=table[tmp%10]; return buf; } int main() { char buf[99]; int aho; for(aho=1; aho<50; aho++){ if( aho%3==0 || aho%5==0 || strchr(itoa(aho,buf,10),'3')) printf("%d\n",aho); } return 0; }
というわけで文字列変換否定しながら、10で割るとか言ってるひとは一体何が言いたいのかわかりません(ぉ
http://codepad.org/zdeQaPMc perl ワンライナーでかいてみた。
perl -le 'do{ print if(/3/||$_%3==0||$_%5==0) } for(1..49);'
http://codepad.org/hHP2CtI5 ちなみに50以降のサポート費とかとれるんなら下記のコードの方が優れている(ぉ
int t_aho[] ={ 3, 5, 6, 9, 10, 12, 13, 15, 18, 20, 21, 23, 24, 25, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 45, 48 }; int is_aho(int aho) { int i; for(i= 0; i< sizeof(t_aho)/sizeof(t_aho[0]); i++) if(t_aho[i] == aho) return aho; return 0; } int main() { int aho; for(aho=1; aho<50; aho++){ if( is_aho(aho) ) printf("%d\n",aho); } return 0; }
機能仕様:
- 入力値が0のとき誤判定します。
- 入力値が50以上の場合判定できません。追加対応により入力値を増やすことができます別途ご相談ください。
客曰く「氏ねよ」