用c语言编程:从键盘上输入一串字母,将其中每一个都变为其后第4个字母如a变为e,如果遇到wxyz,则变为abc 字母译码:输入一个小写字母,输出其后的第四个字符。用c语言写...
C\u8bed\u8a00 \u8f93\u5165\u4efb\u610f\u6570\u91cf\u5b57\u6bcd\u5c06\u5176\u4e2d\u6bcf\u4e00\u4e2a\u90fd\u53d8\u4e3a\u5176\u540e\u7b2c4\u4e2a\u5b57\u6bcd\u4f60\u8fdb\u884c+4\u8fd0\u7b97 \u7684\u5b57\u6bcd\uff0c\u5728 for \u5faa\u73af\u91cc\u9762\uff0c\u800c\u7b2c\u4e00\u4e2a\u8f93\u5165\u7684 \u5b57\u6bcd\uff0c\u5374\u5728 for \u5faa\u73af\u4e0a\u9762\u7684s=getchar();\u4e0a\uff0c\u6839\u672c\u6ca1\u53c2\u4e0e +4\u8fd0\u7b97\uff0c\u4f60\u53ef\u4ee5\u628a \u8fd9\u884c\u5c4f\u853d\u6389\u3002
\u5f97\u5230\u5982\u4e0b\u4ee3\u7801\uff1a
# include int main(){char c;c = getchar();c = (c-'a'+4)%26+'a';putchar(c); return 0;}
void main()
{
printf("请输入一串字母:\n");
char s[100];
scanf("%s",&s);
for(int i = 0;s[i] != '\0';i ++)
{
if(s[i]>='a'&&s[i]<'w')s[i] += 4;
else if(s[i]>='w'&&s[i]<='z')s[i] = 'a'+s[i]-'w';
}
printf("变化后的字符串为:%s\n",s);
}
char c='w';//自己用scanf搞下键盘输入,再搞个循环
printf("%c",(c+4-97)%26+97);//算法
绛旓細include<stdio.h> int j=0,k=0,l=0;int main(){char a[100],*p;void can(char *p);printf("杈撳叆涓涓瓧绗︿覆");p=a;gets(a);can(p);printf("澶у啓瀛楁瘝%d涓猏n",j);printf("灏忓啓瀛楁瘝%d涓猏n",k);printf("鏁板瓧%d涓猏n",l);return 0;} void can(char *p){for(;*p;p++)if((...
绛旓細void main(){ char c;int n=0,s=0;printf("鐜板湪寮濮杈撳叆瀛楃,杈撳叆'-'缁撴潫寰幆锛");while((c=getchar())!='-'){ if(c>='0'&&c<='9')n++;else if(c>='a'&&c<='z')s++;} printf("鏁板瓧瀛楃涓暟鏄%d,灏忓啓瀛楁瘝涓暟鏄%d\n",n,s);getch();} ...
绛旓細printf("%c-%d\t",'a'+i,c[i]);/*杈撳嚭瀛楁瘝a-z鍙婂叾鍑虹幇鐨勬鏁*/ }
绛旓細绋嬪簭璁捐鎬濊矾濡備笅锛氫粠閿洏鍒嗗埆杈撳叆瀛楃涓插拰瑕佺粺璁$殑瀛楃锛岀劧鍚庡姝ゅ瓧绗︿覆浠庡ご寮濮嬮愪釜涓庢墍缁熻鐨勫瓧绗︽瘮杈冿紝濡傜浉鍚岋紝鍒欒璁℃暟鍣ㄥ姞1锛岀煡閬撳瓧绗︿覆鏁翠綋姣旇緝缁撴潫涓烘锛岃鏁板櫒涓氨鏄渶缁熻鐨勫瓧绗︾殑涓暟銆俰nclude "stdio.h"main(){ char str[100],ch; /*瀹氫箟str瀛楃涓诧紝瀹氫箟ch鐢ㄦ潵瀛樻斁瑕佺粺璁$殑瀛楃*/ in...
绛旓細void main(void){ char w[300];int i,j,wl,lm,l;printf("Enter a string composed of words...\n");l=strlen(gets(w));for(wl=lm=j=i=0;i<=l;i++){ if(w[i]!=' ' && w[i]!='\n' && w[i]!='\0') wl++;else if(w[i]==' ' || w[i]=='\n' || w[i...
绛旓細++;n++;/*鍑虹幇鐨勫瓧绗︾殑绉嶇被鏁板姞1*/ } } for(i=0;i<n;i++)/*杈撳嚭*/ printf("\'%c\'鍑虹幇浜%d娆n",ch[i],num[i]);} main(){ int i=0;char s[MAX];printf("璇杈撳叆涓涓瓧绗︿覆:");while((s[i]=getchar())!='\n')/*杈撳叆*/ i++;s[i]='\0';detect(s);} ...
绛旓細include<stdio.h>#include<stdlib.h>int main(){ char a[128]; gets(a); int i=0; int c1,c2,c3,c4; c1=c2=c3=c4=0; while(a[i++]) { if(a[i]>='A'&& a[i]<='Z') c1++; else if(a[i]>='a'&& a[i]<='z') c2++; else if...
绛旓細is_number(char number); //鍒ゆ柇涓涓猚har绫诲瀷鐨勫厓绱犳槸鍚︿负鏁板瓧void delete_all();//鍒犻櫎鍔ㄦ佹暟缁刬nt main(){ini();while (1){get_input();if (is_exit())break;split();delete_all();}delete_all();return 0;}int get_input(){int limit = INI,cnt = 0;char ch;...
绛旓細include<iostream>#include<string.h>using namespace std;void ZhuanHuan(char &); //涓嶉渶瑕佽繑鍥炲糹nt main(){ char a[100]; cout<<"please input a string: "<<endl; cin>>a; for(int i=0;i<strlen(a);i++) { ZhuanHuan(a[i]); } for(int j=0;j...
绛旓細include<stdio.h> void main(){ char *p[20];printf("\n Please input some chars:");scanf("%s",p);printf("\n You inputed: %s\n",p);getchar();} 娉ㄦ剰锛岃绋嬪簭鏈澶氬彲杈撳叆20涓瓧绗︼紝濡傛灉瑕佹洿澶氾紝鑷繁鎶*p[20];閲岀殑鏁板瓧鏀瑰緱鍒楀ぇ灏辫浜 ...