정모/2013.5.6/CodeRace (rev. 1.8)
김현빈, 김태진 ¶
#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;
}
김해천, 임지훈 ¶
#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;
}