2599 - EECS2310_Lec_5 Scoreboard

Time

2022/10/13 08:45:00 2022/10/13 10:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13640 EECS2310_Lec_5_1
13642 EECS2310_Lec_5_2

13640 - EECS2310_Lec_5_1   

Description

#include <stdio.h>
int input(char str[]);
void output(char s[], int len);
int is_palindrome(char s[], int len);

int main(){
   char str[22];
   int len=1;

   len = input(str);
   if(-1 == len){
     printf("invalid input\n");
     return 0;
   }

  output(str, len);
   
  if (is_palindrome(str,len))
      printf("a palindrome\n");
  else
      printf("not a palindrome\n");
   
   return 0;
}

int input(char str[]){
   int len=1;
   char temp_c;
   int i=0;

   do{
     scanf("%c", &temp_c);
     if(temp_c!=' ' && temp_c!='\n')
       str[i] = temp_c;
       i++;
   } while(temp_c!=' ' && temp_c!='\n' && i<22);
   len = i-1;
   if(i>20){
     printf("invalid input\n");
     len= -1;
   }
   return len;
}

   

 

Input

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss




13642 - EECS2310_Lec_5_2   

Description

/* Rewrite this program as stated in the course video */

#include <stdio.h>

void swap(int a, int b){
  int temp;
  temp = a;
  a = b;
  b = temp;
}

int main(void) {
  int x, y;
  scanf("%d %d", &x, &y);

  swap(x,y);
  printf("x=%d, y=%d\n", x, y);
 
  return 0;
}

Input

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss