Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int main() {
- int i=0;
- int j=0;
- int k=0;
- int l=0;
- int m=0;
- char string1[200];
- char string2[200];
- printf("(1) Podaj dowolny ciag znakow:\n");
- scanf("%s",&string1);
- printf("(2) Podaj dowolny ciag znakow:\n");
- scanf("%s",&string2);
- for (i=0;i<200;i++) {
- if (isalpha(string1[i])!=0) {
- k++;
- }
- }
- char tmp1[k];
- for (i=0;i<200;i++) {
- if (isalpha(string1[i])!=0) {
- tmp1[j]=string1[i];
- j++;
- }
- }
- j=0;
- for (i=0;i<200;i++) {
- if (isalpha(string2[i])!=0) {
- l++;
- }
- }
- if (k!=l) {
- printf("Wprowadzone ciagi znakow to nie anagramy!\n");
- return 0;
- }
- else {
- char tmp2[l];
- for (i=0;i<200;i++) {
- if (isalpha(string2[i])!=0) {
- tmp2[j]=string2[i];
- j++;
- }
- }
- for (i=0;i<k;i++) {
- if (isupper(tmp1[i])!=0) {
- tolower(tmp1[i]);
- }
- }
- for (i=0;i<l;i++) {
- if (isupper(tmp2[i])!=0) {
- tolower(tmp2[i]);
- }
- }
- for (i=0;i<k;i++) {
- for (j=0;j<l;j++) {
- if (tmp1[i]==tmp2[j]) {
- m++;
- }
- }
- }
- if (m==i) {
- printf("Wprowadzone ciagi znakow to anagramy!\n");
- }
- else {
- printf("Wprowadzone ciagi znakow to nie anagramy!\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement