LINUX.ORG.RU

История изменений

Исправление LINUX-ORG-RU, (текущая версия) :

dron@gnu:~$ cat c.txt 
Core 0: +39.0°C
Core 1: +39.0°C
Core 2: +38.0°C
Core 3: +36.0°C
Core 4: +38.0°C
Core 5: +37.0°C
Core 6: +39.0°C
Core 8: +40.0°C
Core 9: +38.0°C
Core 0: +42.0°C
Core 1: +38.0°C
Core 2: +41.0°C
Core 3: +39.0°C
Core 4: +40.0°C
Core 5: +39.0°C
Core 6: +42.0°C
Core 8: +38.0°C
Core 9: +38.0°C
dron@gnu:~$ gcc ccc.c -o ~/.local/bin/c2t
dron@gnu:~$ cat c.txt | c2t 
Core 0: +39.0°C    Core 0: +42.0°C  
Core 1: +39.0°C    Core 1: +38.0°C  
Core 2: +38.0°C    Core 2: +41.0°C  
Core 3: +36.0°C    Core 3: +39.0°C  
Core 4: +38.0°C    Core 4: +40.0°C  
Core 5: +37.0°C    Core 5: +39.0°C  
Core 6: +39.0°C    Core 6: +42.0°C  
Core 8: +40.0°C    Core 8: +38.0°C  
Core 9: +38.0°C    Core 9: +38.0°C 
#include <stdio.h>
int main()
{
    int  cnt = 0;
    int  max = 64;
    char buff[2][64][64];
    int  id; float temp;
    while(scanf("Core %d: +%f°C\n",&id,&temp)==2)
    {
        if (buff[0][id][0]=='C')
        {
            sprintf(buff[1][id%max],"Core %d: +%.1f°C",id,temp);
        }else
            sprintf(buff[0][id%max],"Core %d: +%.1f°C",id,temp);
        }

    while(max--)
    {
        (buff[0][cnt][0]=='C')? printf("%s    ",buff[0][cnt]):0;
        (buff[1][cnt][0]=='C')? printf("%s  \n",buff[1][cnt]):0;cnt++;
    }
    return 0;
}

Исходная версия LINUX-ORG-RU, :

dron@gnu:~$ cat c.txt 
Core 0: +39.0°C
Core 1: +39.0°C
Core 2: +38.0°C
Core 3: +36.0°C
Core 4: +38.0°C
Core 5: +37.0°C
Core 6: +39.0°C
Core 8: +40.0°C
Core 9: +38.0°C
Core 0: +42.0°C
Core 1: +38.0°C
Core 2: +41.0°C
Core 3: +39.0°C
Core 4: +40.0°C
Core 5: +39.0°C
Core 6: +42.0°C
Core 8: +38.0°C
Core 9: +38.0°C
dron@gnu:~$ gcc ccc.c -o ~/.local/bin/c2t
dron@gnu:~$ cat c.txt | c2t 
Core 0: +39.000000°C    Core 0: +42.000000°C  
Core 1: +39.000000°C    Core 1: +38.000000°C  
Core 2: +38.000000°C    Core 2: +41.000000°C  
Core 3: +36.000000°C    Core 3: +39.000000°C  
Core 4: +38.000000°C    Core 4: +40.000000°C  
Core 5: +37.000000°C    Core 5: +39.000000°C  
Core 6: +39.000000°C    Core 6: +42.000000°C  
Core 8: +40.000000°C    Core 8: +38.000000°C  
Core 9: +38.000000°C    Core 9: +38.000000°C  
#include <stdio.h>
int main()
{
    int  cnt = 0;
    int  max = 64;
    char buff[2][64][64];
    int  id; float temp;
    while(scanf("Core %d: +%f°C\n",&id,&temp)==2)
    {
        if (buff[0][id][0]=='C')
        {
            sprintf(buff[1][id%max],"Core %d: +%.1f°C",id,temp);
        }else
            sprintf(buff[0][id%max],"Core %d: +%.1f°C",id,temp);
        }

    while(max--)
    {
        (buff[0][cnt][0]=='C')? printf("%s    ",buff[0][cnt]):0;
        (buff[1][cnt][0]=='C')? printf("%s  \n",buff[1][cnt]):0;cnt++;
    }
    return 0;
}