U E D R , A S I H C RSS

정모/2013.5.6/CodeRace (rev. 1.21)

정모/2013.5.6/Code Race

CodeRace 2013

소스코드

김현빈, 김태진

#include <stdio.h>

int main(int argc, const char * argv[])
{
	int aa=0,ab=0,ac=0,i=0;
	char a[4],b[4],c[4],r[4];
	
	FILE* fp;
	fp=fopen(argv[1],"r");
	for(i=0;i<4;i++){
	fscanf(fp,"%s",r);
	if(r[0]=='a'){
		aa++;
		a[0]=r[0];
		a[1]=r[1];
		a[2]=r[2];
	}else if(r[0]=='b'){
		ab++;
		b[0]=r[0];
		b[1]=r[1];
		b[2]=r[2];
	}else if(r[0]=='c'){
		ac++;
		c[0]=r[0];
		c[1]=r[1];
		c[2]=r[2];
	}
	}
	printf("%s %d\n",a,aa);
	printf("%s %d\n",b,ab);
	printf("%s %d",c,ac);
	
	
	return 0;
}

서민관, 조영준

using System;
using System.IO;

namespace CodeRace
{
    class Program
    {
        struct pair
        {
            public string word;
            public int count;
        }

        static void Main(string[] args)
        {
            int size = 100;

            pair[] p = new pair[size];

            int point = 0;

            string[] s;
            string line;
            StreamReader sr = new StreamReader(@"C:\test.txt");
            while ((line = sr.ReadLine()) != null)
            {
                s = line.Split(' ');
                for (int i = 0; i < s.Length; i++)
                {
                    for (int j = 0; j < p.Length; j++)
                    {
                        if (p[j].word == s[i])
                        {
                            p[j].count++;
                            break;
                        }
                        if (j == size-1)
                        {
                            p[point].word = s[i];
                            p[point].count++;
                            point++;
                        }

                    }
                }
            }
            for (int i = 0; i < size; i++)
            {
                if (p[i].word == null) break;
                Console.Write(p[i].word+" "+p[i].count+"\n");
            }
            Console.Read();
        }
    }
}


조성욱, 안정원

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	char buffer[20];
	char store[1000][20];
	int count=0,i;
	int store_count[1000]={0,};
	freopen("input.txt","r",stdin);

	while(scanf("%s ", buffer)!=EOF)
	{
		for(i=0;i<count;i++)
		{
			if(strcmp(buffer,store[i])==0)
			{break;
			}
		}
		if(i==count)
		{
			strcpy(store[count],buffer);
			store_count[count]=1;
			count++;
		}
		else
		{
			store_count[i]++;
		}
	}
	for(i=0;i<count;i++)
	{
		printf("%s %d\n",store[i],store_count[i]);
	}

	fcloseall();
	return 0;
}

송지훈, 김도형

- 문제는 1번만 풀었삼.


#include <stdio.h>

int main()
{
	FILE* fp = fopen("d:\\code_race_prob_1.txt","r");
	char b = 'a';

	while(b != EOF)
	{
		b = fgetc(fp);
		
		if (b=='\n')
			printf("\n");
		else if (b==' ')
			printf("\n");
		else 
		{
			putchar(b);
		}
	}
	fclose(fp);
	system("pause");
	return 0;
}

김해천, 임지훈




#include<stdio.h>
#include<stdlib.h>

int main()
{
	FILE* fp;
	fp=fopen("text.txt","r");
	char some[20],other[10];
	
	fgets(some,20,fp);
	fgets(other,10,fp);
	for(int i=0;some[i]!=NULL;i++)
	{
		printf("%c",some[i]);
		if(!('a'<=some[i] && some[i]<='z'))
		{
			printf("\n");
		}
	}
	for(int i=0;other[i]!=NULL;i++)
	{
		printf("%c",other[i]);
		if(!('a'<=other[i] && other[i]<='z'))
		{
			printf("\n");
		}
	}
	
	fclose(fp);

	return 0;
}



08 장혁수, 13 김한준


1번까지 풀었음

#include <stdio.h>

void main()
{
	int i;
	FILE *file;
	char line[1000];
	file=fopen ("test.txt","rt");

	while( fscanf(file,"%s",&line)==1)
	{
		printf("%s\n",line);

	}
}

팀7

#include <stdio.h>

int main()
{
	int i, j=0;
	int count;
	char buffer[20][20]={};
	char storage[20][20]={};
	char second_storage[20][20]={};

	
	FILE *file = fopen("test.txt", "rt");
	if(file == NULL)
	{
		printf("x");
		return 1;
	}
	for(i=0; i<20; i++)
	{
		fgets(buffer[i], sizeof(buffer), file);
	}
	return 0;
}

고한종,지영민



#include <stdio.h>
/*
 문제1
int main(int argc, const char * argv[])
{
	FILE *code_race=fopen(argv[1], "rt");
	char note[256];
	// insert code here...
	while(!feof(code_race)){
		fscanf(code_race,"%s",note);
		printf("%s\n",note);
	}
	
    return 0;
} 
 */

int main(int argc, const char * argv[]) {
	FILE *code_race=fopen(argv[1], "rt");
	char note[256];
	char paper[128][128];
	int num[128];
	int index=0;
	// insert code here...
	while(!feof(code_race)){
		fscanf(code_race,"%s",note);
		for (int i=0; i<128; i++) {
			if(strcmp(note,paper[i])==0)
			{
				num[i]++;
				break;
			}
		
			
		}
		strcpy(paper[index],note);
		index++;
	}
	// 출력만 하면 되는데 시간이 다 했당.
	return 0;
}




정종록, 이예나

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char a;
		FILE *f;
		char burf[256];
		f=fopen("빡쳐.txt","r");
		fgets(burf,256,f);
		fclose(f);

	return 0;
}


이병윤, 최은정

Q1: cat input | sed  's/ /\n/g'
Q2: cat input|sed 's/ /\n/g'|sort|uniq -c|awk '{print $2, $1}'
Q3: cat input|sed 's/ /\n/g'|sort|uniq -c|awk '{print $2, $1}' | sort
Q4:
#include
#include
int main(){
    char input[1024];
    int i;
    while(1){
        scanf("%s",&input);
        if(input[0] == '\0')
            break;
        else{
            for(i=0;i'=A' && input[i]<='Z')|| (input[i]>='a' &&input[i]<=end.'z'))
                    printf("%c",input[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:54
Processing time 0.0242 sec