Пример #1
0
/* 行をある桁で折り返す */
int main()
{
  int COLS = 30;
  int c, col;

  char buf[1000];
  int i = 0;

  col = 0;

  while ((c = getchar()) != EOF) {
    if (c == '\t')
      col = next_tabstop(col);
    else
      ++col;

    buf[i++] = c;
    if (col == COLS) {
      print_to_last_nonblank(buf, i);
      putchar('\n');
      col = 0;
      i = 0;
    }
    if (c == '\n') {
      print_first(buf, i);
      col = 0;
      i = 0;
    }
  }
  return 0;
}
Пример #2
0
int main()
{
    Sant* santi=(Sant*)malloc(sizeof(Sant));
    initializeSent(santi);
    //santi->head=NULL;
    // santi->tail=NULL;
    char s[30];
    int x;
    out=fopen("out.txt","w");
    in=fopen("in.txt","r");
    int c;
    c=fscanf(in,"%s %d",s,&x);
    while(c>0)
    {
        //printf("%s %d\n",s,x);
        if(!strcmp(s,"AL"))addLast(santi,x);
        if(!strcmp(s,"AF"))addFirst(santi,x);
        if(!strcmp(s,"DE"))delete_element(santi,x);
        if(!strcmp(s,"PRINT_F"))print_first(santi,x);
        if(!strcmp(s,"PRINT_L"))print_last(santi,x);
        if(!strcmp(s,"PRINT_ALL"))printlist(santi);
        if(!strcmp(s,"DOOM_THE_LIST"))doom_the_list(santi);
        if(!strcmp(s,"DF"))delete_first(santi);
        if(!strcmp(s,"DL"))delete_last(santi);
        strcpy(s,"");
        c=fscanf(in,"%s %d",s,&x);

    }
    return 0;
}
Пример #3
0
void print_to_last_nonblank(char *line, int size)
{
  if (size == 0)
    return;

  while (is_space(line[--size]))
    ;

  print_first(line, size+1);
}
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
	print_first();
	int ch;
	do
	{
		start(degree_difficulty());
		printf("1:再来一局\n2:退出\n请选择:");
		fflush(stdin);
		scanf("%d", &ch);
	} while (ch == 1);
	print_last();
	return;
}
Пример #5
0
void LL_construct()
{
	try
	{
		prepare_nonterminals();
		calc_first();
		print_first();
		calc_follow();
		print_follow();
		parse_table_generate();
		print_parse_table();
	}
	catch (ConstructException &e)
	{
		puts(e.message);
		puts("Syntax analyzer construct failed.");
	}
}