week4
NodeList
datastructure
stack
queue
compressor
hashing table
week2
initilaize
int main(int argc, string argv[])
$ ./initials ccc => argc ==2;
$ ./initials ccc => argv[1]==ccc;
//這個卡了我三個小時
if(s[i] == '\0') <--一直想這樣弄結果卡在這
if(s[i] == ' ')
{
i++;
printf("%c", toupper(s[i]));
}
http://imil.au.edu.tw/~hsichcl/TurboC/C_Unit10.htm
http://programming.im.ncnu.edu.tw/Chapter10.htm
caesar 終於卡沒那麼那麼久了 放煙火
printf("%c\n", plaintext[i]);
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
if (argc == 2)
{
string plaintext = get_string();
int key = atoi(argv[1]);
// printf("plaintext:");
// printf("%s\n",plaintext);
for(int i = 0, n = strlen(plaintext); i < n; i++)
{
if(isalpha(plaintext[i]))
{
if(isupper(plaintext[i]))
{
int upc = (plaintext[i] + key - 65) % 26 + 65;
printf("%c", upc);
}else
{
int lpc = (plaintext[i] + key - 97) % 26 + 97;
printf("%c", lpc);
}
}else{
printf("%c", plaintext[i]);
}
}
}
printf("\n");
}
沒有留言:
張貼留言