C/C++の宿題を片付け ..
[
2ch
|
▼Menu
]
■コピペモード
□
スレを通常表示
□
オプションモード
□このスレッドのURL
■項目テキスト
868:867 08/03/30 15:21:42 >>863を把握していなかった。修正。 #include <stdio.h> #include <stdlib.h> #include <string.h> int cmp( const void* key, const void* base ) { const char* key_str = (const char*)key; return strncmp( key_str, (const char*)base, strlen(key_str) ); } int main(void) { static const char base[] = "aaabbc"; // 規定の文字列 const char* hit; char str[101]; printf( "検索文字列:" ); scanf( "%100s", str ); hit = (const char*)bsearch( str, base, strlen(base), 1, cmp ); if( hit ) printf( "'%s'は%d文字目から存在します。\n", str, hit-base+1 ); else printf( "'%s'は存在しません。\n", str ); return 0; } 869:デフォルトの名無しさん 08/03/30 18:03:32 >>864 int x,y; puts(" | 1 2 3 4 5 6 7 8 9\n------------------------------" for(x=1; x<10; x++) { printf("%d | ", x); for(y=1; y<10; y++) printf("%d ", x * y); }
次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
レスジャンプ
mixiチェック!
Twitterに投稿
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch
4990日前に更新/299 KB
担当:undef