squash.c

来自「编程珠玑源代码 很经典 都是c和c++的源代码」· C语言 代码 · 共 27 行

C
27
字号
/* Copyright (C) 1999 Lucent Technologies */
/* From 'Programming Pearls' by Jon Bentley */

/* squash.c -- print anagram classes on a single line    The input lines "opst pots" and "opst stop" go to "pots stop" */#include <stdio.h>#include <stdlib.h>#include <string.h>#define WORDMAX 100int main(){   char word[WORDMAX], sig[WORDMAX], oldsig[WORDMAX];    int linenum = 0;    strcpy(oldsig, "");    while (scanf("%s %s", sig, word) != EOF) {        if (strcmp(oldsig, sig) != 0 && linenum > 0)            printf("\n");        strcpy(oldsig, sig);        linenum++;        printf("%s ", word);    }    printf("\n");
    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?